Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1neFA5-0003ce-Fp for pgsql-admin@arkaria.postgresql.org; Tue, 12 Apr 2022 11:58:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1neFA4-00021q-Dz for pgsql-admin@arkaria.postgresql.org; Tue, 12 Apr 2022 11:58:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1neF6z-0005MU-LV for pgsql-admin@lists.postgresql.org; Tue, 12 Apr 2022 11:55:09 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1neF6x-0004Nl-Db for pgsql-admin@lists.postgresql.org; Tue, 12 Apr 2022 11:55:09 +0000 Received: by mail-qk1-x736.google.com with SMTP id 141so3892587qkf.3 for ; Tue, 12 Apr 2022 04:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=+nn9IN5keXG9/HmcFIBfELZ0s2IOHfVYJBto2fEsf78=; b=nvEITjF4Mim0demWREWGBl9WWDuXkkY5WH0LDd5TIgPq2cotAxZjty5wDAxMSGzEBn UwMQq1tOoWBV19s5WAYS8s3Npxj2EC1H6j3V++O9Bn+DIVPHeRw6FzpkfNn71WqdgnhD BQ2MCAT20QcNbIJxRpi3ppIqZmfKxf0FAHxdy7DDEVSpewUbOCZch/ggzMVFh0qp4Yyd nbRw69P5yHxAbkDO7ya9nI8qvUcbBfyd98JlF0ZrFZxYpK4aMG46+F9SiaenOJxYnzL8 bNKHGRYBJI1l24ymdIICdkP1y2fchG2RbY2OSn1+x2L5FHGcrjcr4iPUuGT+2Kw7s7cu 5y4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=+nn9IN5keXG9/HmcFIBfELZ0s2IOHfVYJBto2fEsf78=; b=cVe89abrsU2jNgvsnDVOl+ehbQkIa4gRQboIEoFPkjmWAA5dHZ5r4KY+hh7g2i1nP4 q7yI42uwQcmqRYMRekVNplIOe/otZDkQe9tB0SMz4niPE5V38uL1H3qoZerFvjEJ36vE iytLRZThndFu17FMLBySIdZSRDAi22OiemWWiOLTujK0biX0E+Pxg7p3vJWY0EiixeiT KwZaKU/bXOreM8OtyBsPNOYV3FGtTMs0ey1KVws+NgIZGLYkS9/KfD+fvpiFQOqGiAg0 kH9mhCNZOBz/uNIIzI3fNm2QfyDowe9O3S5WXIhsEcLAWiIJxvg97kIALoxV+L9xVQB7 yUAg== X-Gm-Message-State: AOAM531zO7jhdY1N4+01w4FFMdSWTBsSiaLFn+9zcbqabCj8H34lthuU OJuRaCZOfATHBDboZDwArvkJ/ZZAbsf2oJOR X-Google-Smtp-Source: ABdhPJwqsuR1j8k+mLaYuW2XHww2nG+ueT10wz/5NkwCu88s9UXSxma3Qg79T9hFBnBs6u18LkwBlQ== X-Received: by 2002:a05:620a:f0d:b0:67e:1961:b061 with SMTP id v13-20020a05620a0f0d00b0067e1961b061mr2783772qkl.82.1649764505096; Tue, 12 Apr 2022 04:55:05 -0700 (PDT) Received: from [192.168.2.100] (pool-72-79-19-93.nwrknj.east.verizon.net. [72.79.19.93]) by smtp.gmail.com with ESMTPSA id 193-20020a3703ca000000b0069bf950dd20sm6401747qkd.43.2022.04.12.04.55.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Apr 2022 04:55:04 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------0B06P41QnedBOJuK0NdM2GDB" Message-ID: Date: Tue, 12 Apr 2022 07:55:03 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: set autocommit only for select statements Content-Language: en-US To: pgsql-admin@lists.postgresql.org References: <548f2ed6-3209-705d-09e2-a5afbc6fb71c@quadratum-braccas.com> <6bfd5d91-bb06-1b56-f4f8-cc8f90307a35@jakobs.com> <005201d84e4b$dce0e6b0$96a2b410$@msym.fr> From: Mladen Gogala In-Reply-To: <005201d84e4b$dce0e6b0$96a2b410$@msym.fr> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------0B06P41QnedBOJuK0NdM2GDB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/12/22 05:01, Michel SALAIS wrote: > What you write about psql sending a COMMIT statement after each statement is wrong. It may be true for other database systems. > > PostgreSQL as a server commits each statement automatically unless the client has started a transaction with BEGIN or START TRANSACTION statements. > > This can be proved easily by not using psql as a client, but some programming language. > > Regards, > > Holger RDBMS, in order to be ACID compliant, deals with transactions, not with single statements. It is the client who starts transaction, not the database. It is also the client who sends commit. And yes, I am also using Python which allows me to set autocommit property: ttps://www.psycopg.org/docs/connection.html#connection.autocommit If I set autocommit connection property to True, each cursor.execute will send a commit. Autocommit cannot be set or disabled on the database level because the database deals with transactions. The point where the transaction is started and finished is the client. That is so for MySQL, that is so for Oracle and that is so for Postgres.BTW, speaking of Python, has anybody here tried Psycopg3? I know it was released but I am not sure whether it's stable enough to use in production? -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com --------------0B06P41QnedBOJuK0NdM2GDB Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
On 4/12/22 05:01, Michel SALAIS wrote:
What you write about psql sending a COMMIT statement after each statement is wrong. It may be true for other database systems.

PostgreSQL as a server commits each statement automatically unless the client has started a transaction with BEGIN or START TRANSACTION statements.

This can be proved easily by not using psql as a client, but some programming language.

Regards,

Holger

RDBMS, in order to be ACID compliant, deals with transactions, not with single statements. It is the client who starts transaction, not the database. It is also the client who sends commit. And yes, I am also using Python which allows me to set autocommit property:

ttps://www.psycopg.org/docs/connection.html#connection.autocommit

If I set autocommit connection property to True, each cursor.execute will send a commit. Autocommit cannot be set or disabled on the database level because the database deals with transactions. The point where the transaction is started and finished is the client. That is so for MySQL, that is so for Oracle and that is so for Postgres.BTW, speaking of Python, has anybody here tried Psycopg3? I know it was released but I am not sure whether it's stable enough to use in production?

-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
--------------0B06P41QnedBOJuK0NdM2GDB--