Zamiel
Zamiel
Explore posts from servers
DTDrizzle Team
Created by Zamiel on 1/1/2024 in #help
How to perform multiple queries?
Ah perfect, I'll use a union, thanks. Any news on the select without from PR?
19 replies
DTDrizzle Team
Created by Zamiel on 1/1/2024 in #help
How to perform multiple queries?
Which might be important at scale when N is not just 3 (like it is in the above code) but is instead 100, for example.
19 replies
DTDrizzle Team
Created by Zamiel on 1/1/2024 in #help
How to perform multiple queries?
Well, I mean to say that they would run at roughly the same speed, but the second one avoids the fixed cost of generating a network packet, the server acknowledging each request, and so on.
19 replies
DTDrizzle Team
Created by Zamiel on 1/1/2024 in #help
How to perform multiple queries?
Sorry, perhaps I am misusing the term "batch queries". Allow me to clarify. Consider the following two SQL queries:
SELECT field_1 from foo WHERE foo.user_id = $1;
SELECT field_2 from bar WHERE foo.user_id = $1;
SELECT field_3 from baz WHERE foo.user_id = $1;
SELECT field_1 from foo WHERE foo.user_id = $1;
SELECT field_2 from bar WHERE foo.user_id = $1;
SELECT field_3 from baz WHERE foo.user_id = $1;
SELECT (
(SELECT field_1 from foo WHERE foo.user_id = $1) as field_1,
(SELECT field_2 from bar WHERE bar.user_id = $1) as field_2,
(SELECT field_3 from baz WHERE baz.user_id = $1) as field_3
);
SELECT (
(SELECT field_1 from foo WHERE foo.user_id = $1) as field_1,
(SELECT field_2 from bar WHERE bar.user_id = $1) as field_2,
(SELECT field_3 from baz WHERE baz.user_id = $1) as field_3
);
In the first query, 3 SQL queries are sent over the wire. In the second query, 1 SQL query is sent over the wire. Isn't the second one faster?
19 replies
DTDrizzle Team
Created by Zamiel on 1/1/2024 in #help
How to perform multiple queries?
Maybe transactions would help? But I'm not quite sure, as I might not need the atomicity of a transaction, since I have a bunch of SELECT statements. (The Drizzle documentation indeed shows a transaction example using INSERT.)
19 replies