Live data from Hacker News

How I slashed a SQL query's runtime with two Unix commands

spinellis.gr

1–10 of 91 posts

Re: How I slashed a SQL query's runtime with two Unix commands

#5
post #4

The question im interested in is why MySQL did not use the index for the lookup.

Not sure if MySQL is the same but Postgres won't use an index if the statistics suggest doing so will be slower than a full table scan - would expect MySQL to be similar.

With 5bn+ rows and a memory constraint, the type of index begins to make a difference - e.g. in Postgres I would have tried using a bloom index.

Re: How I slashed a SQL query's runtime with two Unix commands

#7
post #3
post #2

Try a real analytical database such as Vertica

What is the definition of a real analytical database?

by analytical database I think the person meant a columnar database. for mysql compatible examples that means infobright or infinidb.

Re: How I slashed a SQL query's runtime with two Unix commands

#10
post #5
post #4

The question im interested in is why MySQL did not use the index for the lookup.

Not sure if MySQL is the same but Postgres won't use an index if the statistics suggest doing so will be slower than a full table scan - would expect MySQL to be similar. With 5bn+ rows and a memory constraint, the type of index begins to make a difference - e.g. in Postgres I would have tried using a bloom index.

It can be very frustrating that, even with updated statistics, the optimizer decides to go a different way with a query. While using Sybase, this happened quite a lot when tables got rather large (corporation large not Google large). The normal response is to force the indexes on the query. Due to log space issues, I do remember having an awk script between queries back in the Ingres days.
Post reply on HN