Re: [SQL] Question about index/constraint definition in a table

2013-10-09 Thread David Johnston
David Johnston wrote > > JORGE MALDONADO wrote >> I have a table as follows: >> >> Table Artist Colaborations >> >> * car_id (integer field, primary key) >> * car_song (integer field, foreign key, for

Re: [SQL] Question about index/constraint definition in a table

2013-10-09 Thread David Johnston
JORGE MALDONADO wrote > I have a table as follows: > > Table Artist Colaborations > > * car_id (integer field, primary key) > * car_song (integer field, foreign key, foreign table is a catalog of > son

[SQL] Question about index/constraint definition in a table

2013-10-09 Thread JORGE MALDONADO
I have a table as follows: Table Artist Colaborations * car_id (integer field, primary key) * car_song (integer field, foreign key, foreign table is a catalog of songs) * car_artist (integer field, for

Re: [SQL] Question about index scan vs seq scan when using count()

2006-02-23 Thread Owen Jacobson
Kashmira Patel wrote: > I did do an EXPLAIN ANALYZE as well, it also showed a > sequential scan. The table has about 600+ rows, with around 6 of them > matching the given id. Wouldn't an index scan be faster in this case? Not necessarily. It's entirely possible, if your rows are small, that 600

Re: [SQL] Question about index scan vs seq scan when using count()

2006-02-23 Thread Kashmira Patel \(kupatel\)
Sent: Thursday, February 23, 2006 2:47 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Question about index scan vs seq scan when using count() On Thu, Feb 23, 2006 at 02:25:34PM -0800, Kashmira Patel (kupatel) wrote: > > [Kashmira] I did do an EXPLAIN ANALYZE as well, it also sh

Re: [SQL] Question about index scan vs seq scan when using count()

2006-02-23 Thread Andrew Sullivan
On Thu, Feb 23, 2006 at 02:25:34PM -0800, Kashmira Patel (kupatel) wrote: > > [Kashmira] I did do an EXPLAIN ANALYZE as well, it also showed a > sequential scan. The table has about 600+ rows, with around 6 of them > matching the given id. Wouldn't an index scan be faster in this case? EXPLAIN AN

Re: [SQL] Question about index scan vs seq scan when using count()

2006-02-23 Thread Kashmira Patel \(kupatel\)
: [SQL] Question about index scan vs seq scan when using count() > What am I doing wrong here? I want it to use my index. For small tables the sequential scan is faster, that means less disk reads is required the whole table than to use the index. If it is a large table, the index should be u

Re: [SQL] Question about index scan vs seq scan when using count()

2006-02-23 Thread Kashmira Patel \(kupatel\)
> For example: I have a table vm_message with an index on column msgid. > Will the following do a sequential scan or an index? > > select count(*) from vm_message where msgid = 3; How much of the table is that? How many rows? EXPLAIN ANALYSE will tell you if you have the right plan (estimate

Re: [SQL] Question about index scan vs seq scan when using count()

2006-02-23 Thread Andrew Sullivan
On Thu, Feb 23, 2006 at 01:44:43PM -0800, Kashmira Patel (kupatel) wrote: > My understanding of this statement is that if I use count() without a > WHERE clause, then essentially, it is applied to the entire table and > hence requires a seq scan. > But it should not require a seq scan if I have a c

[SQL] Question about index scan vs seq scan when using count()

2006-02-23 Thread Kashmira Patel \(kupatel\)
Hello,    I am using postgres version 7.4, and I read this in the documentation:   "The aggregate functions sum and count always require a sequential scan if applied to the entire table."   My understanding of this statement is that if I use count() without a WHERE clause, then essentially

Re: [SQL] question about index

2004-12-16 Thread D'Arcy J.M. Cain
On Thu, 16 Dec 2004 11:41:54 +0100 Jerome Alet <[EMAIL PROTECTED]> wrote: > For a future databas, I plan to have got a table with a text field > which can contain only three different values, say "VALUE1", > "VALUE2", and "VALUE3" Can it increase? That is, can a "VALUE4" be added half way thro

Re: [despammed] [SQL] question about index

2004-12-16 Thread Andreas Kretschmer
am 16.12.2004, um 11:41:54 +0100 mailte Jerome Alet folgendes: > Hi, > > For a future databas, I plan to have got a table with a text field > which can contain only three different values, say "VALUE1", > "VALUE2", and "VALUE3" Why text-fields for this task? I would prefer a smallint for this

[SQL] question about index

2004-12-16 Thread Jerome Alet
Hi, For a future databas, I plan to have got a table with a text field which can contain only three different values, say "VALUE1", "VALUE2", and "VALUE3" this table may have, over the course of one year, several million rows for a size around 2 Gb or more. I'd be interested in having :