jeudi 2 juillet 2015

How to read different data in a given column of a SQLite database very fast?

I have the following situation: there is a table where one of its columns is a date-time string. What I want to do is to know which years are mentioned in this table, that is: I want to read all lines in the column "date-time" and see which of them have a year different from my "already mentioned years list"; if a given row has a year not yet added, I add that year to my list and at the end I'll have all mentioned years.

Now naturally enough I know how to do this in a very costful algorithm which would be a literal implementation of the text above. What I would like to know is if there is a fast way, maybe more "native", of doing such kind of query - you can just imagine the huge processor cost I'll get if I try to implement an algorithm exactly as told above.

Any better ideas?

Details: I'm programming with C++/Qt and the table may be big (like 10000 rows or more).

Aucun commentaire:

Enregistrer un commentaire