[Kde-pim] Review Request 121310: Optimize queries: Do not retrieve known key used in the condition.
Milian Wolff
mail at milianw.de
Tue Dec 2 15:19:03 GMT 2014
> On Dec. 2, 2014, 3:15 p.m., Daniel Vrátil wrote:
> > I'm willing to bet that DBs can optimize these cases internally, so the only benefit would really be less data transmitted between DB and application.
> >
> > But won't the fact, that each column has to be stored in a new variable cause the code to actually be slower than transmitting few more bytes to and from DB? The patch itself is OK, but I'm just wondering if there's actually any gain?
What do you mean by "each colums has to be stored in a new variable"? The `variableN` temporaries? Compilers will optimize that. Sadly, the gain is there, because Qt SQL is highly unoptimized. When I have some time, I'll improve it, but currently there are multiple memory allocations involved when reading a value from a SQL result. Thus using the string or ID directly gets rid of a ton of temporary allocations. Furthermore this patch ensures that e.g. the name is implicitly shared. If you read the value from the SQL result, you'll get a new string with the same contents.
So to summarize: I also think/hope that databases can optimize this internally. But since Qt SQL is pretty bad in that regard, we do see a noticeable effect of this patch.
- Milian
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/121310/#review71180
-----------------------------------------------------------
On Dec. 1, 2014, 1:21 p.m., Milian Wolff wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/121310/
> -----------------------------------------------------------
>
> (Updated Dec. 1, 2014, 1:21 p.m.)
>
>
> Review request for Akonadi, Daniel Vrátil and Volker Krause.
>
>
> Repository: akonadi
>
>
> Description
> -------
>
> There is no point in doing a select like:
>
> SELECT foo, bar FROM table WHERE foo = needle;
>
> That can be rewritten to say
>
> SELECT bar FROM table WHERE foo = needle;
>
> This reduces the data traffic with the mysql server.
>
>
> Diffs
> -----
>
> server/src/storage/entities.xsl 94712933564a8f6c1bf99502e4af837f5934d41e
>
> Diff: https://git.reviewboard.kde.org/r/121310/diff/
>
>
> Testing
> -------
>
> it works!
>
>
> Thanks,
>
> Milian Wolff
>
>
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/
More information about the kde-pim
mailing list