dbTalk Databases Forums  

Re: Seq scan with a like operator

comp.databases.postgresql.admin comp.databases.postgresql.admin


Discuss Re: Seq scan with a like operator in the comp.databases.postgresql.admin forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Peter Eisentraut
 
Posts: n/a

Default Re: Seq scan with a like operator - 07-23-2004 , 09:54 AM






Am Freitag, 23. Juli 2004 14:50 schrieb Jouneau Luc:
Quote:
I don't understand why with a like operator, PostgreSQL 7.4.2 does not
behave the same as with an equal operator :
LIKE requires a different kind of index. See
<http://www.postgresql.org/docs/7.4/static/indexes-opclass.html>.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
  #2  
Old   
Jouneau Luc
 
Posts: n/a

Default Re: Seq scan with a like operator - 07-23-2004 , 10:24 AM






Quote:
LIKE requires a different kind of index. See
http://www.postgresql.org/docs/7.4/static/indexes-opclass.html>.
Thanks for the answer peter,

I didn't notice it when I red the doc, but if I create the index as
specified then it is the query with equal operator which use a seq scan.
Do I have to create 2 indexes on the same column (with different datatype)
in order to support different kind of queries ?
Well, It seems quite strange to me :
Suppose you have an user interface in which user can parameter his query on
4 varchar fields (independantly, i.e field 4 does not need to have field 1,2
or 3 filled), and you allow to use generic character such as '*' or '?'
(which will be translated into '%' and '_'). User can also fill in exact
values.
Then you would have to create 4*2=8 indexes to handle every combinations of
possible queries.

It would also mean that support both exact generic queries double the
indexing task on update/insert/delete.

Am I wrong ?

Luc Jouneau


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings



Reply With Quote
  #3  
Old   
Peter Eisentraut
 
Posts: n/a

Default Re: Seq scan with a like operator - 07-23-2004 , 11:00 AM



Am Freitag, 23. Juli 2004 17:24 schrieb Jouneau Luc:
Quote:
I didn't notice it when I red the doc, but if I create the index as
specified then it is the query with equal operator which use a seq scan.
Do I have to create 2 indexes on the same column (with different datatype)
in order to support different kind of queries ?
Yes.

Quote:
Well, It seems quite strange to me :
Suppose you have an user interface in which user can parameter his query on
4 varchar fields (independantly, i.e field 4 does not need to have field
1,2 or 3 filled), and you allow to use generic character such as '*' or '?'
(which will be translated into '%' and '_'). User can also fill in exact
values.
I think that kind of interface would use the LIKE operator no matter whether
the user entered wildcards or not.

Quote:
It would also mean that support both exact generic queries double the
indexing task on update/insert/delete.
Well, if you want to optimize lots of different queries, the system needs to
provide lots of different support.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.