开发者

Fast search within strings in PostgreSQL

Which is the fastest way to search within string in PostgreSQL (case insensivity):

SELECT col FROM table WHERE another_col ILIKE '%typed%'

or

SELECT col FROM table开发者_JS百科 WHERE another_col ~* 'typed'

How can I turn on showing the time which query need to return results? Something like is on default in mySQL (I am thinking about CLI client).


Both queries are the same, PostgreSQL rewrites ILIKE to ~*. Check the results from EXPLAIN to see this behaviour.

I'm not sure about your question, but the psql-client can show you some timing of the query, using \timing.


Regarding the timing:

One solution is to use the switch for psql that Frank has already mentioned.

When you use EXPLAIN ANALZYE it also includes the total runtime of the query on the server.

I prefer this when comparing the runtime for different versions of a query as it removes the network from the equation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜