Hi everyone, Thank you for your answers.
Arkade: You mentioned transactions. I believe they're not relevant here because every read is still executed synchronously (i.e. Django process waits for database to respond.) Tom: Thank you for understanding what I'm looking for :) You said "The only way I could see it having any non-marginal effect is if you have high latency to your database server. But then you have a lot of problems." Well, I'm using Heroku, so a database query that takes 1ms on my local dev machine takes 3ms there, presumably because on my dev machine the database is running on the same machine as the Django server, where in Heroku the database is on a separate machine. I think that many other people are in the same scenario, so allowing to do multiple queries in the same roundtrip would be helpful to many people. Here is what I'm currently thinking about: Can we make Django do multiple separate queries (SQL queries are separated by a semicolon right? Sorry for being a noob) and send them one after another before blocking on reading any of them? Only then when everything is sent, start reading and populating querysets. *Is this possible to do with Django?* Thanks for your help, Ram Rachum. On Sat, Feb 28, 2015 at 12:40 AM, Michael Manfre <mman...@gmail.com> wrote: > Stored procedures, at least with MSSQL, provide another way of returning > multiple result sets with a single SQL statement. The queries will be > parsed and executed faster due to stored procedures being parsed and > compiled when created, instead of when executed. A stored procedure will > also allow you to get more complex results with a few simple queries, > instead of a single complex query. > > Using stored procedures adds complexity to a Django project and should be > used sparingly. From my personal experience, the extra server resources to > have more instances running to service requests is usually better than > having the extra complexity of using stored procedures in a Django project. > > Regards, > Michael Manfre > > On Fri, Feb 27, 2015 at 2:46 PM, Tom Evans <tevans...@googlemail.com> > wrote: > >> On Fri, Feb 27, 2015 at 3:19 PM, aRkadeFR <cont...@arkade.info> wrote: >> > What do you mean by a single roundtrip? >> >> He means asking the database server to consider multiple queries >> (concurrently?), and return data once all of them are available. In >> pseudo code: >> >> people, jobs, cities = DB.fetch_multi( >> Person.objects.all(), >> Job.objects.all(), >> City.objects.all()) >> >> MySQL's C API supports executing multiple SQL statements in a single >> round trip, the data sets are made available in turn to the client API >> >> http://dev.mysql.com/doc/refman/5.7/en/c-api-multiple-queries.html >> >> however, each statement is executed in turn, not concurrently, so the >> only speed up you would have is that there is only one query to parse, >> and a few small packets less sent to the database server... The >> database connection is not torn down between requests to the database. >> >> The only way I could see it having any non-marginal effect is if you >> have high latency to your database server. But then you have a lot of >> problems. >> >> Cheers >> >> Tom >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django developers (Contributions to Django itself)" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-developers+unsubscr...@googlegroups.com. >> To post to this group, send email to django-developers@googlegroups.com. >> Visit this group at http://groups.google.com/group/django-developers. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-developers/CAFHbX1%2BMgfwHL%3DL8hjgRMyf%2B2-Rap9L01PF9cxERFqU6c8uHdA%40mail.gmail.com >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django developers (Contributions to Django itself)" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-developers/3Lk-HEF16iI/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at http://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/CAGdCwBuxXXSTrB68YFQ503RAfxH1z_BBxpytLk-75gwuGs3-zw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-developers/CAGdCwBuxXXSTrB68YFQ503RAfxH1z_BBxpytLk-75gwuGs3-zw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CANXboVYY2xGzzBb_3b5BPEBJeNCFjVqK6g02giLdcT4x-2BSrQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.