[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    [HACKERS] Odd select behavior -- statistics, redux (7.0.x and devel)
From:       mlw <markw () mohawksoft ! com>
Date:       2000-11-30 12:26:27
[Download RAW message or body]

When Postgres is fast, it is really fast. I love it. My biggest problem
is when/how it chooses best path, it seems to me that relatively few
records with a high duplication destroy performance. I can't stress
enough that this is a serious problem in the real world.

Take these two queries:

cdinfo=# explain select trackid, song, title   from zsong, ztitles where
ztitles.performer2 like 'Van Halen' and ztitles.muzenbr= zsong.muzenbr
and contains(song, 'panama', 10)>0;
NOTICE:  QUERY PLAN:

Merge Join  (cost`12.55..182151.93 rows902 width6)
  ->  Sort  (cost`12.55..6012.55 rows130 width)
        ->  Index Scan using ztitles_performer2_ndx on ztitles
(cost=0.00..5830.80 rows130 width)
  ->  Index Scan using zsong_muzenbr_ndx on zsong  (cost=0.00..166961.86
rowss1071 width )

cdinfo=# explain select trackid, song, title   from zsong, ztitles where
ztitles.title like 'Van Halen' and ztitles.muzenbr = zsong.muzenbr and
contains(song, 'panama', 10)>0;
NOTICE:  QUERY PLAN:

Nested Loop  (cost=0.00..93.45 rows=4 width6)
  ->  Index Scan using ztitles_title_ndx on ztitles  (cost=0.00..7.08
rows=1 width)
  ->  Index Scan using zsong_muzenbr_ndx on zsong  (cost=0.00..78.43
rows=7 width )

They are fundamentally the same query, each with an index, each doing
about the same thing. Except that the performer2 field has a high number
of duplicate records ala "Various Artists"

Now we have had some small debates about how to fix this, and perhaps I
am over simplifying it, but the current statistics are broken, they do
not work reliably and produce unreliable results. I think this is a must
for 7.1. A simple hack, such as discarding the upper and lower %5-10%
should be able to fix this behavior, without too many side effects (if
any). While I agree it is not the "right" way to do something, it would
be a "better" way of doing something that is currently wrong.

With the exception of this problem, I love postgres, but this problem
really goes a long way to make it look REAL bad.

BTW anyone know a way around this?

--
http://www.mohawksoft.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic