On Fri, Jun 25, 2010 at 6:49 AM, P Kishor <punk.k...@gmail.com> wrote:
> Is there any gotcha, any disadvantage (query complexity, db size,
> query speed) to using a composite PK (two columns) vs. a single
> AUTOINCREMENT INT?
>
> Background: I happen to have the two columns in question in my table
> anyway. Adding an INTEGER PRIMARY KEY would use up space I don't want
> to use. My db is big enough to worry about space from a single field.

Primary keys that are not a single integer are equivalent in storage
and complexity to a separate additional index, and composite keys
don't have any penalty over single-column keys.

Single integer primary keys you get for free.  They take no extra
storage or complexity because in SQLite every table already has one
even if you don't use it (called a "rowid").  Specifying one merely
gives it a new name.

-- 
Cory Nelson
http://int64.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to