Do I need to create an index on text columns when doing LIKE 'something%'?

23 views
Skip to first unread message

philip andrew

unread,
May 15, 2012, 10:33:06 AM5/15/12
to h2-da...@googlegroups.com
Hi there,

I read in the documentation "When comparing with LIKE, the wildcards characters are _ (any one character) and % (any characters). The database uses an index when comparing with LIKE except if the operand starts with a wildcard."

Does that mean I should create an index on that column? or is the index automatically created or used somehow?

Thanks, Philip

Ryan How

unread,
May 15, 2012, 10:59:25 AM5/15/12
to h2-da...@googlegroups.com
Hi,

I think you need to create it. You can always run EXPLAIN and see if the query is using an index or not. So if it isn't, then try creating one, then see if it uses it. It would work without the index, it would just be slower.

http://www.h2database.com/html/grammar.html#explain
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/ofb28NxeRisJ.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

Reply all
Reply to author
Forward
0 new messages