![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a very slow query when enable_seqscan=on and very fast when enable_seqscan=off. |
|
-> Seq Scan on organization (cost=0.00..480.95 rows=1 width=4) (actual time=0.071..69.702 rows=1892 loops=1) Filter: ((organization_location)::text ~* 'warszawa'::text) |
#3
| |||
| |||
|
|
I have a very slow query when enable_seqscan=on and very fast when enable_seqscan=off. My schema looks like this (relevant columns only): PS. Actual table and column names are different (they're in Polish) but I've translated them for better readability for english-speaking. |
|
PS. I wonder if it makes sense to "enable_seqscan=off" for every client if a database is small enough to fit in OS cache. |
|
-> Seq Scan on organization (cost=0.00..480.95 rows=1 width=4) (actual time=0.071..69.702 rows=1892 loops=1) Filter: ((organization_location)::text ~* 'warszawa'::text) |
#4
| |||
| |||
|
|
-> Seq Scan on organization (cost=0.00..480.95 rows=1 width=4) (actual time=0.071..69.702 rows=1892 loops=1) Filter: ((organization_location)::text ~* 'warszawa'::text) How many rows are there in the organization table? |
|
This is probably the fault of the pattern-selectivity heuristic: it's far too optimistic about long match strings eliminating a lot of rows. I think there's been some discussion of modifying that logic but no one's really stepped up with a better idea. |
#5
| |||
| |||
|
|
I think because there is no good solution to this - no statistical information is going to predict how much data will match a regular expression. |
#6
| |||
| |||
|
|
I think the real problem here is that regex matching is the wrong tool for the job. Have you looked into a full-text index (tsearch2)? |
|
With something like that, the index operator has at least got the correct conceptual model, ie, looking for indexed words. I'm not sure if they have any decent statistical support for it :-( but in theory that seems doable, whereas regex estimation will always be a crapshoot. |
#7
| |||
| |||
|
|
On Tue, 04 Jul 2006, Tom Lane wrote: =20 I think the real problem here is that regex matching is the wrong tool for the job. Have you looked into a full-text index (tsearch2)? =20 So much to do with so little time... |
#8
| |||
| |||
|
|
So why estimate regex expressions if there is no estimation possible? Let's set this estimate to be pessimistic (match everything or everything not null) and it will choose better plans. |
#9
| |||
| |||
|
|
Tomasz Ostrowski <tometzky (AT) batory (DOT) org.pl> writes: So why estimate regex expressions if there is no estimation possible? Let's set this estimate to be pessimistic (match everything or everything not null) and it will choose better plans. Better plans for this specific example, worse plans for other cases. Life is not that simple. |
![]() |
| Thread Tools | |
| Display Modes | |
| |