Tilted Forum Project Discussion Community

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology
New! Use your Facebook, Google, AIM & Yahoo accounts to securely log into this site, click logo to login  
Register Register Blogs Members List Mark Forums Read

Reply
 
LinkBack Thread Tools
Old 05-05-2004, 11:33 AM   #1 (permalink)
Banned from being Banned
 
Location: Donkey
[SQL Server] Do positions of columns/fields affect performance?

Say I have a table with 10 fields. The very last field has a data type of DateTime, which I frequently perform searches with.

In addition to indexing, would it make the query faster if I repositioned that field (in the table's design) so that it was in the front? Instead of being:

Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9, DateField

It would be:

DateField, Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9


Kind of a silly question, but I always wondered if field positioning had any effect on how well a query performed. In theory it makes sense because if that date field was at the front as opposed to being behind 9 other fields, it seems the DB wouldn't have to sift through as much data to find what it needs.

On the otherhand.. I have no idea how a DB actually performs the searches, so it might not matter. Just wanted additional input on this.

Thanks!
__________________
I love lamp.
Stompy is offline   Reply With Quote
Old 05-05-2004, 11:15 PM   #2 (permalink)
Crazy
 
Location: Salt Town, UT
Not a real DBA, but a MySQL guy

Taking MySQL and PostgreSQL as my examples, the only way it would make a difference is on full-table scans, and only if the columns in front of it are of variable length (VARCHAR's etc). Anytime you are resorting to full-table scans, your database is going to be slow (after about 50 columns, full-table scans loose out completely to indexed data) so the itty bit of speed you would stand to gain is most likely not worth it.

But if you have an index for that column, it should be stored in a different location from the actual data, and should make it not matter one little bit where the column is located.

From a design perspective however, the most important columns typically go first (at least in the schemas I build), but that's a guideline without any real reason for it.
Rawb is offline   Reply With Quote
Reply

Bookmarks

Tags
affect, columns or fields, performance, positions, server, sql

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 02:29 PM.

Contact Us - Tilted Forum Project - Archive - Top

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
All text © 2002-2009 Tilted Forum Project
"Insignia" vBulletin 3.5 - b6gm6n - x7x7x7.com