Re: Should I add a Index Key in this case ?

Rob Sargent <[email protected]> Wed, 16 Oct 2019 10:05:26 -0600
Newsgroups gmane.comp.db.postgresql.sql
Message-ID <[email protected]>
--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 <[email protected]> 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 =
<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

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><br =
class=3D""><div><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D"">On Oct 16, 2019, at 9:47 AM, Karen Goh &lt;<a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><!--[if gte mso =
9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:Pixe=
lsPerInch></o:OfficeDocumentSettings></xml><![endif]--><div class=3D"">
Hi Steve,<div class=3D""><br class=3D""></div><div class=3D"">My =
question is should I use index on the Seat_Viewing_id ?</div><div =
class=3D""><br class=3D""></div><div class=3D"">I have no experience in =
using Index hence I asked if it should be made =
auto-incremental?</div><div class=3D""><br class=3D""></div><div =
class=3D"">Kindly advise how should I alter my existing table to have =
index.&nbsp;</div><div class=3D""><br class=3D""></div><div =
class=3D"">Tks!<br class=3D""><br =
class=3D""></div></div></div></blockquote>alter table doc here:&nbsp;<a =
href=3D"https://www.postgresql.org/docs/10/sql-altertable.html" =
class=3D"">https://www.postgresql.org/docs/10/sql-altertable.html</a><br =
class=3D""></div><div>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. &nbsp;Perhaps you should share your current table =
definition?</div><div>I think you may need a seat_viewing table, in =
which you place the id of the viewed seats. &nbsp;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.</div><br =
class=3D""></body></html>=

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