Re: [Feature Request] Performant values_list query

2015-11-16 Thread cristianocca28
Nice you tested it out! You are right about that kind of optimization is really a micro optimization and would only help if there were a bunch of those related. De: Josh Smeaton Enviado el: ‎lunes‎, ‎16‎ de ‎noviembre‎ de ‎2015 ‎23‎:‎48 Para: django-developers@googlegroups.com I finally

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Josh Smeaton
I finally got djangobench running, but I find the results too unpredictable. I resorted to some simple timeit measurements which I've shown here: https://gist.github.com/jarshwah/f28d84987aadc7bcb2f5 Result.. moving the if outside of the loop has about a 15% decrease in time taken for that bloc

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Josh Smeaton
Hey, Nice to see most of the performance differences are resolved. Most of the heavy lifting will actually be compiling the SQL that is going to be executed now I think. You might want to take a look at generating the SQL yourself and executing directly with connection.cursor if you're still h

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Tim Graham
We don't patch the docs for versions of Django older than the latest stable release except in critical cases. For one, this causes problems for the translated versions of the docs because there's no process for updating those older versions. Also, Django 1.7 will be unsupported in a couple week

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Cristiano Coelho
You beat me to it. Yes I have just tested under django 1.8.6, and the issue I started this with is gone, both values_list and a direct raw query perform as good, so this is definetly an issue only on django 1.7.10 or less. I can not test django 1.9 since my project is not really compatible with

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Josh Smeaton
The version of Django you use is going to have a large (code) impact on what is actually happening when calling values_list. The Values[List]QuerySet classes are gone in 1.9. 1.8 implemented a different/better way of converting values from the database to python. from_db_value came about in 1.8

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Cristiano Coelho
Hi, I have downloaded the actual source code, and I have probably forgot to mention that I'm using django 1.7.10. It seems like the compiler.py module got a little bit improved since then, what used to be a big and highly inefficient loop with many if conditions inside was reduced to a small loo

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Cristiano Coelho
Interesting, maybe because I'm using MySQL with mysqlclient connector, but running the straight query with the django cursor wrapper always returns the correct data types, even dates with its it time zone when time zone is enabled, was it all coincidence? Would using a different backend break wi

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Marc Tamlyn
To give some brief historical context: values_list has been around a LONG time, so I wouldn't say anyone has consciously designed it with performance in mind above "it's faster than complete model loading". The most noticeable thing which your code does not do which an implementation of values lis

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Tim Graham
I don't think there is much database backend specific logic as far as values_list() goes, but if you get something working on SQLite and send a pull request, we can easily run it on all database backends. For performance testing, you might find https://github.com/django/djangobench/ useful. On

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Cristiano Coelho
Hi, thanks for the response! I have never developed nor ran the django test suite, I can certainly try as you mentioned, I was hoping for anyone that actually implemented values_list to give me a solid reason to not do any change as I'm probably wrong and the current way it is implemented is the

Re: [Feature Request] Performant values_list query

2015-11-16 Thread Anssi Kääriäinen
I don't think anybody has anything against making values() or values_list() queries faster. The question is purely about implementation. If you can offer something that is faster than the current code without introducing backwards incompatibilities or making the code a lot more complex, then such a

[Feature Request] Performant values_list query

2015-11-16 Thread Cristiano Coelho
I would like to add, that minor change on a critical query meant an increase from 37 to 47 requests per second on a benchmark test with apache, that's a 22% improvement that will be bigger on larger results (this was just with 700 rows result set), compared to using some pagination with a limit

[Feature Request] Performant values_list query

2015-11-15 Thread cristianocca28
After some testing I have found out that even when using values_list to prevent massive object creation when fetching data, it is from 2 to 3 times slower tan using directly a cursor.execute query through the django cursor. The issue started here http://stackoverflow.com/questions/33726004/dja