0

Let's assume I have two tables of the same row count. Both tables contain a column that allows for 1-1 join between them. If those tables were turned into one table instead and thus JOIN statement eliminated from the query, would there be any performance benefit of that?

Another example... Let's assume I have table with 10 columns. From that table I created new table but only taking one column. If I issue statement selecting that one column with WHERE predicate on the same column would there be any performance difference in executing this query on both tables?

What I'm trying to get to is if performance is the same in above cases is it safe to say tables are only containers wrapping number of columns together?

I did run couple tests but with non conclusive results.

marcin_koss
  • 5,763
  • 10
  • 46
  • 65

1 Answers1

3

Let's assume I have two tables of the same row count. Both tables contain a column that allows for 1-1 join between them. If those tables were turned into one table instead and thus JOIN statement eliminated from the query, would there be any performance benefit of that?

Performing that join for every query is of course more expensive than materializing the table once and then reading it. So yes, there would be a performance benefit.

Another example... Let's assume I have table with 10 columns. From that table I created new table but only taking one column. If I issue statement selecting that one column with WHERE predicate on the same column would there be any performance difference in executing this query on both tables?

No, there would be no difference, since tables are represented as collections of columns, which are each stored in their own file.

What I'm trying to get to is if performance is the same in above cases is it safe to say tables are only containers wrapping number of columns together?

That is indeed safe to say.

Hannes Mühleisen
  • 2,542
  • 11
  • 13
  • In first example If I created a view from those two tables would the effect be still same as just using join on them in each query? – marcin_koss Apr 12 '15 at 13:25