Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iKlnr-0005Nr-1k for pgsql-sql@arkaria.postgresql.org; Wed, 16 Oct 2019 16:05:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iKlnp-0000gT-E0 for pgsql-sql@arkaria.postgresql.org; Wed, 16 Oct 2019 16:05:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iKlnp-0000gC-2I for pgsql-sql@lists.postgresql.org; Wed, 16 Oct 2019 16:05:33 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iKlnm-0004mj-I6 for pgsql-sql@lists.postgresql.org; Wed, 16 Oct 2019 16:05:31 +0000 Received: by mail-pf1-x441.google.com with SMTP id q12so15002993pff.9 for ; Wed, 16 Oct 2019 09:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=x+tfDLnlCKunxKwqV9qUCBWYEgUn8L6gKv0xTV4mB0Q=; b=i588rPUwjC7KHeRDFY7KW6w5sxUKUbQ2T3rkHISBXOdC547rcapIK5XUH5XG9zz7iX UETtzOX6FHRoN5YSW6kEMNnElWD5EGCSNDX7giJqnD5PZ1ZNtuikB+oMFjKuYv+OCIHE w7D/me4vTcXeotPGSPfRMTiP73/x17M6dgCAyu68LSiPVD2NQ/7BVBeTwm+/NfyNjoLs esu9D80iaFFGiwfEq77ewpMTF/tJr+mYgo/bHxfDDiRz1kjkf9CSEXT1bz58nphoJBsB e4tlgURRTz1c1wAeuFcW67pX9dKj1JZGP7ZUj/4VZtHrK3UKmKehM0XZb1mNwkq6E5dU K4gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=x+tfDLnlCKunxKwqV9qUCBWYEgUn8L6gKv0xTV4mB0Q=; b=U9zVIQ1tJ5LsfaZhZFo62Bfb8z+hZZk6TPmYKTWnCoMlXedrEuDgfLlmOlOF2dCSVz cYp+JS00upqy8ryXkgiZF1O5Y8eZhzNgUP7eh618eqN+dWC9q+GqsLGzHzdFPZLeDte5 wz1AN6xy9PfywOecpnygv3jEVcWrIFfS7hkzA0dXlfkU0MUwVsFgjCdNkRl4BYYMvr0U Lr3VL+ZDFr8srPWwTcHhELOlkv73KhXSKndorasA3aiZRbvz3ytr3d/fHqTWftBTjmLQ 0i6dUZSCOuD0/nb+8cNjD92gBeJI9vzOpju25VaRhKyoKgHDB+TO2CatZb2vVaDb0Ctr foAQ== X-Gm-Message-State: APjAAAV6TFekEw6K6ZvmAmCG+g9rAzNZrSvAI6FAK6EdzSJRTPD78+9S AM6SJaoXdcb4jojJcjT1dHk= X-Google-Smtp-Source: APXvYqyiYjEsugl71kpM4CM0U+pcQgG+U2XNOWwzL0Vc68pgf8AP27+uJY6LlcdRsUNE8PfrZjvc6w== X-Received: by 2002:a63:ff1c:: with SMTP id k28mr45872991pgi.281.1571241928809; Wed, 16 Oct 2019 09:05:28 -0700 (PDT) Received: from [192.168.1.108] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id w6sm31894659pfw.84.2019.10.16.09.05.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Oct 2019 09:05:27 -0700 (PDT) From: Rob Sargent Message-Id: <11B38F25-EED7-478D-9B02-7D1DF67A5862@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_B818D664-3AB3-4B41-A5EA-7E86C0CAE55B" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: Should I add a Index Key in this case ? Date: Wed, 16 Oct 2019 10:05:26 -0600 In-Reply-To: <1747806136.1620685.1571240832461@mail.yahoo.com> Cc: Steve Midgley , pgsql-sql@lists.postgresql.org To: Karen Goh References: <1846839195.1533405.1571225796919@mail.yahoo.com> <1747806136.1620685.1571240832461@mail.yahoo.com> X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_B818D664-3AB3-4B41-A5EA-7E86C0CAE55B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Oct 16, 2019, at 9:47 AM, Karen Goh wrote: >=20 > Hi Steve, >=20 > My question is should I use index on the Seat_Viewing_id ? >=20 > I have no experience in using Index hence I asked if it should be made = auto-incremental? >=20 > Kindly advise how should I alter my existing table to have index.=20 >=20 > Tks! >=20 alter table doc here: = https://www.postgresql.org/docs/10/sql-altertable.html = you will likely need an index on that new column, though it=E2=80=99s = not clear to how you wish to fill in the value for existing rows. = Perhaps you should share your current table definition? I think you may need a seat_viewing table, in which you place the id of = the viewed seats. You would want a unique index on the new table using = the existing seat id but you do NOT want the column to be of type = serial, just (big?) integer. --Apple-Mail=_B818D664-3AB3-4B41-A5EA-7E86C0CAE55B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Oct 16, 2019, at 9:47 AM, Karen Goh <karenworld@yahoo.com> wrote:

Hi Steve,

My = question is should I use index on the Seat_Viewing_id ?

I have no experience in = using Index hence I asked if it should be made = auto-incremental?

Kindly advise how should I alter my existing table to have = index. 

Tks!

alter table doc here: https://www.postgresql.org/docs/10/sql-altertable.html
you will likely need an index on that new column, = though it=E2=80=99s not clear to how you wish to fill in the value for = existing rows.  Perhaps you should share your current table = definition?
I think you may need a seat_viewing table, in = which you place the id of the viewed seats.  You would want a = unique index on the new table using the existing seat id but you do NOT = want the column to be of type serial, just (big?) integer.

= --Apple-Mail=_B818D664-3AB3-4B41-A5EA-7E86C0CAE55B--