Live data from Hacker News

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

spinellis.gr

51–60 of 91 posts

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

#51
After reading the post, and considering the time of export/import the data, I think will be better to denormalize the data (ie:precalculate the result).

I have something like in the near past, but with much heavy calculations. Denormalizing using triggers turn query that take minutes in less 1 second.

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

#52

Am I missing something fundamental like a WHERE clause? I see a join, but no limiting of rows beyond that.

You're right - this query doesnt make sense, because if he's left joining, he should at least do

where tableB.someCol != null

or something. Otherwise, the join is useless (or he should use an inner join)

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

#53
post #22

I'd also like to see a breakdown of the time taken to complete the project. RAM is cheap and jumping from 16GB to 64GB (or even 128GB) might have cost as much as the analysis time. The only clue to that a memory upgrade might have been a quicker fix was that the merged file was 133G. Seems to me that an upgrade to 128GB of RAM might have led to a dramatically shorter query execution time.

Yes, having tables with the size of 5B rows on a machine with 16GB RAM is just stupid, going to the disk will most probably always happen.

Just because it's slow doesn't make it stupid; parsimonious maybe, but not stupid. Just my 2c.

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

#57

The distinct on the date format is the problem, probably should use a separate query on each table to fill in the date output as a new column first, and then join afterwards. Also wrong tool for the job comes to mind. MariaDB/MySQL are just not great at joins and query planning, and at this scale, especially with all the work involved to export and use unix tools, why not use any of the columnar data warehouses that…

[deleted]

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

#59
I once had a huge performance problem for a simple self-join that I expected would run quickly.

I talked to our resident SQL expert (retired from IBM, now doing a job as the lab administrative assistant). She suggested sorting the data before inserting it.

That sped up the query.

it still bother me that data order matters so much. But, I can't reproduce the problem in MySQL any more anyway.

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

#60
post #7
post #3

Earlier quoted context omitted.

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.

In the original case, pretty much any real (as in NOT My/Maria) database would've worked (knowing how to use it would've helped, of course), but for columnar analytics Monet is pretty nice, too, and ever so slightly cheaper than Vertica.
Post reply on HN