Re: [PERFORM] Planner making wrong decisions 8.2.4. Insane cost calculations.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Henrik Zagerholm <henke(at)mac(dot)se>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, pgsql-performance(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: [PERFORM] Planner making wrong decisions 8.2.4. Insane cost calculations.
Date: 2007-08-06 15:31:51
Message-ID: 27852.1186414311@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

Henrik Zagerholm <henke(at)mac(dot)se> writes:
> WHERE file_indexed IS FALSE
> AND file_copied IS TRUE
> AND file_size < (1024)
> AND LOWER
> (file_suffix) IN(
> SELECT LOWER
> (filetype_suffix) FROM tbl_filetype_suffix WHERE
> filetype_suffix_index IS TRUE
> ) AND fk_archive_id
> = 115 ORDER BY fk_tar_id

Do you really need the lower() calls there? The planner is getting the
wrong estimate for the selectivity of the IN-clause, which is likely
because it has no statistics about lower(file_suffix) or
lower(filetype_suffix).

If you don't want to constrain the data to be already lower'd, then
setting up functional indexes on the two lower() expressions should
prompt ANALYZE to track stats for them.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Keaton Adams 2007-08-06 15:44:02 Template zero xid issue
Previous Message Gregory Stark 2007-08-06 15:31:14 Re: [PERFORM] Planner making wrong decisions 8.2.4. Insane cost calculations.

Browse pgsql-performance by date

  From Date Subject
Next Message Henrik Zagerholm 2007-08-06 15:50:22 Re: Extreme slow select query 8.2.4
Previous Message Gregory Stark 2007-08-06 15:31:14 Re: [PERFORM] Planner making wrong decisions 8.2.4. Insane cost calculations.