From: | Melvin Davidson <melvin6925(at)gmail(dot)com> |
---|---|
To: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: PostgreSQL Developer Best Practices |
Date: | 2015-08-24 12:58:56 |
Message-ID: | CANu8FiwKH=1aB5Qx8ytkgXXnDyA_gCD7p9O1JA9W9AKwx_R=aA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
David,
Thank you. This is exactly the type of feedback I was looking for. To
answer your question, for now it is a guide for one particular client,
however, if I get enough feedback and contributions, I will revise it and
submit to the PostgreSQL community.
On Mon, Aug 24, 2015 at 2:34 AM, Thomas Kellerer <spam_eater(at)gmx(dot)net> wrote:
> Melvin Davidson schrieb am 22.08.2015 um 17:15:
> > I've attached a file with a few starters that although are numbered,
> > are in no special order.
>
>
> > 2. End ALL queries with a semi-colon (;)
> > EG: SELECT some_column FROM a_table;
> >
> > Although autocommit is on by default, it is always a good idea to
> signal the query processor that a statement is complete with the semicolon.
> > Failure to do so could result in <IDLE IN TRANSACTION>, which will
> > hold locks on the tables involved and prevent other queries from
> being processed.
>
> Terminating a statement with ; has nothing to do with "<idle in
> transaction>" connections.
> It is a mere syntax thing to make the SQL client (e.g. psql) recognize the
> end of the statement.
> If you don't use it, your statement won't be executed in the first place -
> at least with psql
> as it will wait indefinitely until you finish typing the statement. A GUI
> client might simply send
> the wrong statement to the backend.
>
> If you run with autocommit disabled, ending each statement with a
> semicolon, will not prevent your connection
> from getting into that "<idle in transaction>" state. You have to end the
> _transaction_ using commit or
> rollback to avoid that.
>
> I do agree with the "end all queries with a semi-colon" rule, but the
> explanation is wrong.
>
> You should have another rule that says:
>
> End all transactions as soon as possible using commit or rollback.
>
> Thomas
>
>
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.
From | Date | Subject | |
---|---|---|---|
Next Message | Ray Cote | 2015-08-24 13:15:27 | Re: PostgreSQL Developer Best Practices |
Previous Message | Thomas Kellerer | 2015-08-24 06:34:33 | Re: PostgreSQL Developer Best Practices |