[Kmymoney-devel] Review Request 122138: [GCI2014] Find the maximum in a set of numeric strings.

Christian Dávid christian-david at web.de
Sun Feb 1 11:54:42 UTC 2015


Hi Daniel,

of course you can contact me/us any time. Help is always appreciated :)

The different SQL queries are not an issue, I just thought they are more 
similar.

I am quite sure the way you solved the issue is the right one. Doing a "SELECT 
id FROM table;" and then doing the comparison in C++ is probably even slower 
than your solution. The bottle neck for speed is reading the data and only the 
RDBMS can optimize this process. Also why should we copy the hole data (should 
be about 0.3MB for 10  000 transactions + a lot of overhead) just to receive 
one number? Imaging the data must be send through a network. The RDBMS must be 
really slow to be slower than solving this issue in C++ [1].

I wish you good luck and success for your studies!

Greetings
Christian

Am Sonntag, 1. Februar 2015, 07:45:54 schrieb Daniel Ring:
> I would like to stay, but unfortunately my studies will require my full-time
> attention starting next week. I may be able to return once this semester
> ends. Should I contact you again then?
> 
> I had hoped to make the queries more similar as well, but unfortunately not
> all databases treat text as zero when converting strings to numbers. It may
> be less computationally expensive to simply retrieve all records from the
> database with a simple `SELECT` statement and determine the highest number
> with a `for` loop and `q.value(0).toString().mid(prefixLength).toULong()`
> (toULong() returns 0 if the conversion fails). It would resolve the test
> issue as well, since only one query would be necessary for all RDBMSs.
> 
> The function is called `highestIdNumString()` because it returns the string
> used to get the highest id number from the database, though
> `highestNumberFromIdString()` does sound better.
> 
> Once again, thank you for all the help, and I hope we can work together
> again soon!



More information about the KMyMoney-devel mailing list