Does performance improve by limiting the columns fetched?
Posted: Tue Feb 12, 2008 12:46 am
Hi there friends, well this is not a problem or anything but just an information that i am keen on knowing. In our current working environment, we make a single function to list all the data from a table. Now few of these tables have over 100 columns while some have blog data in them. Currently If i have to fetch data from just few columns from a particular table, i just use the function to retrieve all the column values. Now it seems obvious that fetching just say 2 column values must be faster than fetching all, but some of my fellow mates think that the overhead is really really really LESS... none the less i made a function (with regex and explode and well it's all messy) which accepts an array which contains column names or aliases to recreate a SQL which fetches only the desired columns. The thing is I need your opinion on the function i made too, rather than going through explodes and regex would it be better option to just put the actual query inside another select?? I mean like this say: i have a SQL like this
I would be thankful for any suggestions .. really..long live devnetwork
Now is it better to for my function to do:SELECT cloumn1,columns2,columns3........,columnN FROM some_table WHERE condition
Or is it better for my function to go through explodes and regex to generate SQL like this:SELECT column1,columns3 FROM (SELECT cloumn1,columns2,columns3........,columnN FROM some_table WHERE condition)
SELECT cloumn1,columns3........,columnN FROM some_table WHERE condition
I would be thankful for any suggestions .. really..long live devnetwork