Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 05-05-2004, 10: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  
Old 05-05-2004, 10: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  
 

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 01:30 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73