mysql - SELECT TableName.Col1 VS SELECT Col1 -


this might weird question didnt know how research on it. when doing following query:

  select foo.col1, foo.col2, foo.col3   foo   inner join bar on foo.id = bar.bid 

i tend use tablename.column instead of col1, col2, col3

is there performance difference? faster specify table name each column?

my guess yes faster since take time lookup column name , and differentiate it.

if knows link read on grateful. did not know how title question better since not sure how search on it.

first of all: should not matter. time columns such miniscule fraction of total processing time of typical query, might wrong spot additional performance.

second: tablename.colname is faster colname only, eliminates need search referenced tables (and table-like structures views , subqueries) fitting column. again: difference inside statistical noise.

third: using tablename.colname is idea, other reasons: if use colname only, , 1 of tables in query gets new column same name, end oh-so-well-known "ambiguous column name" error. typical candidates such columns "comment", "lastchanged", , friends. if qualify col references, maintainability problem disappears - query work allways, ignoring new fields.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -