Why does PostgresQL query performance drop over time, but restored when rebuilding index

后端 未结 5 1165
慢半拍i
慢半拍i 2021-01-31 18:59

According to this page in the manual, indexes don\'t need to be maintained. However, we are running with a PostgresQL table that has a continuous rate of upd

5条回答
  •  借酒劲吻你
    2021-01-31 19:46

    Is the '2010-05-20T13:00:00.000' value that xmlscheduledtime is being compared to, part of the SQL, or supplied as a parameter?

    When planning how to run the query, saying that a field must be less than a supplied parameter with an as yet unknown value doesn't give PostgreSQL much to go on. It doesn't know whether that'll match nearly all the rows, or hardly any of the rows.

    Reading about how the planner uses statistics helps tremendously when trying to figure out why your database is using the plans it is.

    You might get better select performance by changing the order of fields in that complex index, or creating a new index, with the fields ordered (campaignfqname, currentstate, xmlscheduledtime) since then the index will take you straight to the campaign fq name and current state that you are interested in, and the index scan over the xmlscheduledtime range will all be rows you're after.

提交回复
热议问题