Re: A general way to batch SQL queries in Django

2015-03-01 Thread Guilherme Leal
I don't think your problem is related to Django at all, but with the way that SQL work instead. There's no sense in batch a query that return values from your DB (unless you're doing 1 query per connection, witch is a stupid thing to do IMO). Em sex, 27 de fev de 2015 às 11:18, Ram Rachum escreve

Re: A general way to batch SQL queries in Django

2015-03-01 Thread Aymeric Augustin
2015-02-28 22:05 GMT+01:00 Ram Rachum : > 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

Re: A general way to batch SQL queries in Django

2015-03-01 Thread Shai Berger
On Saturday 28 February 2015 23:05:56 Ram Rachum wrote: > > 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 t

Re: A general way to batch SQL queries in Django

2015-02-28 Thread Ram Rachum
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 wa

Re: A general way to batch SQL queries in Django

2015-02-27 Thread Michael Manfre
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

Re: A general way to batch SQL queries in Django

2015-02-27 Thread Tom Evans
On Fri, Feb 27, 2015 at 3:19 PM, aRkadeFR 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( Pers

Re: A general way to batch SQL queries in Django

2015-02-27 Thread Tim Chase
On 2015-02-27 06:12, Josh Smeaton wrote: > The concept of batched SELECT statements doesn't really exist in > SQL, unless the relations you're selecting have identical column > types. Example: > > SELECT name, age_in_years FROM person > UNION ALL > SELECT item_name, quantity FROM item; > > The UN

Re: A general way to batch SQL queries in Django

2015-02-27 Thread aRkadeFR
What do you mean by a single roundtrip? You can do multiple queries in a single transaction (thus in a single connection to the DB). By default (correct me if I'm wrong) with PG for example, it does all the queries in a single transaction while being in a request. On 02/27/2015 03:18 PM, Ram

Re: A general way to batch SQL queries in Django

2015-02-27 Thread Ram Rachum
Thank you for the explanation. I still wonder though: you asked what the result set would look like, given it's two different tables. What I want is multiple result sets, but in only one roundtrip. Is it possible to send multiple SQL queries to the database in one roundtrip? We'd need the second qu

Re: A general way to batch SQL queries in Django

2015-02-27 Thread Josh Smeaton
The concept of batched SELECT statements doesn't really exist in SQL, unless the relations you're selecting have identical column types. Example: SELECT name, age_in_years FROM person UNION ALL SELECT item_name, quantity FROM item; The UNION here means combine the results of each query into the

A general way to batch SQL queries in Django

2015-02-27 Thread Ram Rachum
Hi guys, After asking this question on django-users: https://groups.google.com/forum/#!topic/django-users/EuPduHjSNos And in several other forums, and not finding a solution, I've reached a conclusion: It would be really helpful to allow batching SQL queries in Django. I should preface by sayi