-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support RETURNING in modification commands #242
Comments
i use peewee (orm) in a rather complex worker queue. |
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 ORMs like to have their 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 |
I just chatted with @anarazel on this. We have two ways to implement this:
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. |
Hey @ozgune I don't understand what executing this on the master even means. Approach two is what I was going to suggest. |
@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 |
On 2016-03-17 21:07:23 -0700, Jason Petersen wrote:
True. But those are much less common. The most common reason to use |
Ran into this again during a customer engagement. It was again because their ORM was issuing |
+1 - We are running into the same issue while evaluating CitusDB |
Without returning the generated primary key, how do you know what to put in a foreign key without adding the "returning" clause? Yes, I could insert a record then select that record to get the pk value, but that seems inefficient to me. |
@anarazel and I talked about this last week; and I'm summarizing our meeting notes. @anarazel -- if I have inaccuracies in this description, could you point them out? We talked about the architectural implications of executing (1) If we implement pipelined write statements on the master node: In this model, the client speaking to the master node supports pipelined execution. We then split into two alternatives: (1.a) The master node maintains a persistent queue. When the client sends This pipelined execution model is incompatible with doing Two questions that relate to this model are: (i) What happens if the (1.b) The master node queues up (2) In the v5.0 replication model, we have shard replicas living on separate machines. If we push down Also, if we wanted to implement We're currently evaluating changing Citus' replication model. In this updated model, we will have one primary replica and multiple secondary replicas. If we go with the new replication model, (3) It's easier to implement these changes on the master node given the way
We also talked about -- if we wanted to later support CTEs in (4) We also briefly touched upon |
Removed 5.1 milestone from this issue. |
@digi604 @brianbroderick @brettallred @rodo Do you need INSERT RETURNING or also UPDATE / DELETE / INSERT ON CONFLICT ... RETURNING? We're looking at implementing the feature, and your answer would help determine the shape of it. |
yeah, we use upserts all the time so having the "on conflict" clause is important to me. |
Mainly |
When is 5.2 Release planned? since this feature was moved to 5.2 Release. |
@francisco1844 -- we intend to officially release v5.2 end of July. We expect this feature to go into the master branch earlier than that; and we'll keep this issue updated. |
Two additional quick notes. (1) ActiveRecord / Ruby only supports simple Apart from custom-written CTEs, RETURNING is not used in UPDATE or DELETE statements. It also looks like you can disable this behavior using the "insert_returning: false" config option. In that case it looks like it'll run a SELECT currval(..) on the sequence after the INSERT (typically within the same transaction). (2) Sequel just inserts the |
@ozgune @marcocitus @sumedhpathak Any opinion on whether it's ok to send the RETURNING to all nodes? My current implementation does so, and just consumes (ignores) the results for RETURNING for all but the first. I tend to think that's ok. |
I think that's fine. |
Thursday Jul 23, 2015 at 15:23 GMT
Originally opened as citusdata/pg_shard#128
Any query using the
RETURNING
clause produces the following error:Can you add support for
RETURNING
clauses?The text was updated successfully, but these errors were encountered: