You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Comment by jasonmp85 Monday Jul 27, 2015 at 19:56 GMT
Hey Patrick Lauber (@digi604): What's your use case? We didn't implement RETURNING to keep the feature profile abbreviated during the initial release, but with sufficient demand we could change that. 😃
In ORM (I know it's bad, but sometimes we have to work with people who love them) like Django the SQL query include RETURNING to return the object's id to the ORM, maybe Patrick Lauber (@digi604) uses an ORM.
I vote for RETURNING support in pg_shard 👍
This feature came up again. If the query executed on a single shard, how hard would it be to implement? Would we need to keep the returned values from INSERT statements on the master node?
ORMs like to have their INSERT statements to have RETURNING expressions:
returning id -- returning null
FEELINGS_DB.run(Sequel.lit("insert into observation_hash(id, created_at, server_id, data)
values(?,?,?,?)",
(feeling_id+i).to_s(16).rjust(32,'0'),
Time.now,
(server_id+i).to_s(16).rjust(32,'0'),
data
))
# vs
FEELINGS_DB[:observation_hash] << {
id: (feeling_id+i).to_s(16).rjust(32,'0'),
created_at: Time.now,
server_id: (server_id+i).to_s(16).rjust(32,'0'),
data: dat
Execute the RETURNING statement on the master node: Andres Freund (@anarazel) notes that this approach is much easier to integrate into the PostgreSQL machinery. Andres, could you note this approach's benefits?
Push the RETURNING statement to the worker node. In this approach, we'll push down the query and store results returned from the worker node in a tuple store. In this approach, we could also cover UPDATE statements that touch a single shard.
I'm also noting #213 and #240 as semi-related issues. At a higher level, we could evaluate expressions on the master node and route these requests, or evaluate them on the workers. This decision may also relate to our replication model.
I don't understand what executing this on the master even means. RETURNING is part of an UPDATE, INSERT, or DELETE command that returns a particular column. It would make the most sense to push this down.
Jason Petersen (@jasonmp85) The point of not pushing RETURNING down, at the very least for INSERT, is that it a) allows for easy and correct evaluation of now(), nextval(), etc. b) doesn't prevent going to a pipelined execution model c) is actually easier to implement given how RETURNING works in postgres.
Right, but what about UPDATE count = count + 1 RETURNING count? Isn't stuff like that a pretty common pattern, too? Or DELETE FROM accounts WHERE id = 5 RETURNING balance? That is more straightforward if you push the clause down, no?
On 2016-03-17 21:07:23 -0700, Jason Petersen wrote:
Right, but what about UPDATE count = count + 1 RETURNING count?
Isn't stuff like that a pretty common pattern, too? Or DELETE FROM accounts WHERE id = 5 RETURNING balance? That is more
straightforward if you push the clause down, no?
True. But those are much less common. The most common reason to use
RETURNING is for ORMs after an INSERT, to get the generated key et al.
Activity
citus-github-bot commentedon Feb 4, 2016
Monday Jul 27, 2015 at 19:56 GMT
Hey Patrick Lauber (@digi604): What's your use case? We didn't implement
RETURNINGto keep the feature profile abbreviated during the initial release, but with sufficient demand we could change that. 😃citus-github-bot commentedon Feb 4, 2016
Sunday Aug 09, 2015 at 17:05 GMT
In ORM (I know it's bad, but sometimes we have to work with people who love them) like Django the SQL query include
RETURNINGto return the object's id to the ORM, maybe Patrick Lauber (@digi604) uses an ORM.I vote for
RETURNINGsupport inpg_shard👍citus-github-bot commentedon Feb 4, 2016
Tuesday Aug 11, 2015 at 07:52 GMT
i use peewee (orm) in a rather complex worker queue.
ozgune commentedon Mar 16, 2016
This feature came up again. If the query executed on a single shard, how hard would it be to implement? Would we need to keep the returned values from
INSERTstatements on the master node?ORMs like to have their
INSERTstatements to haveRETURNINGexpressions:returning id -- returning null FEELINGS_DB.run(Sequel.lit("insert into observation_hash(id, created_at, server_id, data) values(?,?,?,?)", (feeling_id+i).to_s(16).rjust(32,'0'), Time.now, (server_id+i).to_s(16).rjust(32,'0'), data )) # vs FEELINGS_DB[:observation_hash] << { id: (feeling_id+i).to_s(16).rjust(32,'0'), created_at: Time.now, server_id: (server_id+i).to_s(16).rjust(32,'0'), data: datozgune commentedon Mar 18, 2016
I just chatted with Andres Freund (@anarazel) on this. We have two ways to implement this:
RETURNINGstatement on the master node: Andres Freund (@anarazel) notes that this approach is much easier to integrate into the PostgreSQL machinery. Andres, could you note this approach's benefits?RETURNINGstatement to the worker node. In this approach, we'll push down the query and store results returned from the worker node in a tuple store. In this approach, we could also coverUPDATEstatements that touch a single shard.I'm also noting #213 and #240 as semi-related issues. At a higher level, we could evaluate expressions on the master node and route these requests, or evaluate them on the workers. This decision may also relate to our replication model.
jasonmp85 commentedon Mar 18, 2016
Hey Ozgun Erdogan (@ozgune)
I don't understand what executing this on the master even means.
RETURNINGis part of anUPDATE,INSERT, orDELETEcommand that returns a particular column. It would make the most sense to push this down.Approach two is what I was going to suggest.
anarazel commentedon Mar 18, 2016
Jason Petersen (@jasonmp85) The point of not pushing RETURNING down, at the very least for INSERT, is that it a) allows for easy and correct evaluation of now(), nextval(), etc. b) doesn't prevent going to a pipelined execution model c) is actually easier to implement given how RETURNING works in postgres.
jasonmp85 commentedon Mar 18, 2016
Right, but what about
UPDATE count = count + 1 RETURNING count? Isn't stuff like that a pretty common pattern, too? OrDELETE FROM accounts WHERE id = 5 RETURNING balance? That is more straightforward if you push the clause down, no?anarazel commentedon Mar 18, 2016
On 2016-03-17 21:07:23 -0700, Jason Petersen wrote:
True. But those are much less common. The most common reason to use
RETURNING is for ORMs after an INSERT, to get the generated key et al.
samay-sharma commentedon Apr 12, 2016
Ran into this again during a customer engagement. It was again because their ORM was issuing
INSERTqueries which had aRETURNINGclause.brettallred commentedon Apr 14, 2016
+1 - We are running into the same issue while evaluating CitusDB
16 remaining items
Support RETURNING for modification commands.
Support RETURNING for modification commands.
Bump CI PG minors to 16.15/17.11/18.6 (the-process #242 dev images)
[CI only] Bump PG minors to 16.15 / 17.11 / 18.6 (#8777)
[CI only] Bump PG minors to 16.15 / 17.11 / 18.6 (#8777)