I have a simple table:
MyTable
id int null
user varchar(50) null
desc varchar(150) null
No PK or indexes of any kind.
Does the following cause any performance issue:
insert into MyTable (desc, user, id) values ('Bob from Account
Temps','Bob','777')
Does not having indexes or PK hinder the insert? And does the order of the
columns in the insert make a difference?
Thanks all
JDEvery table should have a primary key. Why do you have a table without
one?
> Does not having indexes or PK hinder the insert?
A lack of indexes and constraints doesn't affect the insert per se.
Potentially it affects the *validity* of the insert since you won't be
prevented from inserting redundant data.
> And does the order of the
> columns in the insert make a difference?
If all the column names are listed then logically the order makes no
difference.
David Portas
SQL Server MVP
--|||This is a 3rd party application. I'm trying to gather information what will
be presented at a meeting next week.
thanks for the feedback.
JD
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1108586063.090431.233100@.l41g2000cwc.googlegroups.com...
> Every table should have a primary key. Why do you have a table without
> one?
>
> A lack of indexes and constraints doesn't affect the insert per se.
> Potentially it affects the *validity* of the insert since you won't be
> prevented from inserting redundant data.
>
> If all the column names are listed then logically the order makes no
> difference.
> --
> David Portas
> SQL Server MVP
> --
>|||>> Does not having indexes or PK hinder the insert?
> A lack of indexes and constraints doesn't affect the insert per se.
It can, but the effect will probably only surface under more extreme conditi
ons.
If there is a clustered index, SQL Server will immediately know where to put
this row. If the cl ix
key is always increasining (which isn't necessarily the optimal cl ix key fo
r *searches*), then you
won't get page splits either.
If there isn't a cl ix, then SQL Server need to go by IAMs and PFS pages (I
believe, it is still
early in the morning for me) to determine where to put the rows. I imagine t
hat this can be more
work, but I doubt we see the effect unless large databases and heavy load.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1108586063.090431.233100@.l41g2000cwc.googlegroups.com...
> Every table should have a primary key. Why do you have a table without
> one?
>
> A lack of indexes and constraints doesn't affect the insert per se.
> Potentially it affects the *validity* of the insert since you won't be
> prevented from inserting redundant data.
>
> If all the column names are listed then logically the order makes no
> difference.
> --
> David Portas
> SQL Server MVP
> --
>
No comments:
Post a Comment