Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tJldn-00527X-0d for pgsql-general@arkaria.postgresql.org; Sat, 07 Dec 2024 03:37:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tJlck-00EpSH-O3 for pgsql-general@arkaria.postgresql.org; Sat, 07 Dec 2024 03:36:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tJlck-00EpS9-5z for pgsql-general@lists.postgresql.org; Sat, 07 Dec 2024 03:36:55 +0000 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tJlci-001Rg6-Sf for pgsql-general@lists.postgresql.org; Sat, 07 Dec 2024 03:36:54 +0000 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-e396cc8c9a1so2656485276.0 for ; Fri, 06 Dec 2024 19:36:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733542611; x=1734147411; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=miHlK+iv83Q8FGnBRcopxBgbwHdxiYjxfRURvvBQ42E=; b=IWOWc8f8LFnFiaIIycMmsq30U3BhkB8MhlSj6mg74aT1fTIfy2lD4q/GykV6zysA1X sN6I0EAp8eyN0TjS7jNpYxIpT7nJxO0Bx1Em/nOUorukWlPgPaCwY2tAcBleP4W91RV2 XGHNREkj5smg7WN3rad3Xq0TeF19OA2oCd+BVodlV2oRvvoPDNxuNwNNoWp70T0C4GG9 16ZR+mVZjTfLS26XqaGfqxOPDJA2l9yosroPWBZHIn6EvFRwvuV4FoxhwrKDhl86AJ4V edYzYNobqIVWFeJGRuSt8vj6xzMvaUWmD00g7JNa7tISMQQ7MgZ8L5KKPehtfEvZFNcV Ko1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733542611; x=1734147411; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=miHlK+iv83Q8FGnBRcopxBgbwHdxiYjxfRURvvBQ42E=; b=lB16CibwQkJwMQkTiZoGU+XPknLXM0/+EthnAHE0xaLaxnAaMqtZ4N9QkivdT4+ho2 NGrEsWbjy3ZIyHclfNdrKo3ORuWYHtelzkZeXAfQNKULgeEjdwx+ryyVOmZD/bL/FoL1 uVN8rO4a3kh78gO+xHMut0vaEJY2isXRhh//06dhWE4DkcIF6StTZbLP+Ir82ePge1JR 08cZAdJE9vbiMLb9itDD1dnzB9oZWEQ13K7/O+yo7ym1Ad3+oktULYEVvLh4JKoQvwK2 e+i3FTfCbv+3dP6vdd5/59fY396Duybkjs7bXoyrsZEuUipp1eF2erPklhx+ztI/lbsk VT0Q== X-Gm-Message-State: AOJu0Yy2FD22nWt/2OzNhMfO647wsT1GbAOa7TjAT6Zgy/t0/rKI6TQs r1HmuG2AS8xDlFry3A4/+2F3U6veIDr5/GoBHmZyosL1a3axC/+TcCCSic8pnIEtaPFqnsKLlwk 4TjqNNPW7Q8gKyqQcdXBgBubaDhah0A== X-Gm-Gg: ASbGncsjHa6G3EJJAW0KQpRNOZ4OlTdSAAqtj1WqfELwprW4x4c4hxFDjqxLvfo+GpR enfPxoYn06wgpIRtQb1juAldtoT4zJC9/zJeQFoY2/9HAZUO5qBxzjj50LAWM8KwX X-Google-Smtp-Source: AGHT+IE11YE0Conwf2ik9vDVtgwZEOOM66hWVpxTLc37L7Fb61fg8eXfV3qlVaOaihvd0c1JIOwnyEPwXUOwRwa5NEo= X-Received: by 2002:a05:6902:102c:b0:e33:9d45:117e with SMTP id 3f1490d57ef6-e3a0a860745mr5252705276.20.1733542611230; Fri, 06 Dec 2024 19:36:51 -0800 (PST) MIME-Version: 1.0 From: Igor Korot Date: Fri, 6 Dec 2024 21:36:40 -0600 Message-ID: Subject: Insert records in the tavke only if they are not exist To: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000008be9a80628a5d7b6" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000008be9a80628a5d7b6 Content-Type: text/plain; charset="UTF-8" Hi, All, When my application starts up, ot creates some tables and insert records in them. When the app starts for the second time it should check if the tables and the records in them are exist and skip the process. Everything is good, except what if I have a connection from 2 different users? I can run this inside transaction, but will this be enough? Will stating transaction lock the DB and the second user will wait for transaction to complete? Thank you. --0000000000008be9a80628a5d7b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, All,

Whe= n my application starts up, ot creates some tables and insert records in th= em.

When the app starts = for the second time it should check if the tables and the records in them a= re exist and skip the process.

Everything is good, except what if I have a connection from 2 differ= ent users?

I can run thi= s inside transaction, but will this be enough? Will stating transaction loc= k the DB and the second user will wait for transaction to complete?

Thank you.

--0000000000008be9a80628a5d7b6--