lars peterson
lars peterson

Reputation: 29

Fast request to Database

Iam curious about if knowing an ID instead of an item name will be a faster way to request data in a Database? and therefore also get a faster data respons.

Thanks

Upvotes: 0

Views: 43

Answers (1)

reaanb
reaanb

Reputation: 10066

Possibly but not necessarily. It could even be slower. It depends on how the tables were defined.

The name of a column has no impact on the performance. The type can have a tiny impact, the size affects performance a little bit more.

What's most important to the performance of large tables is indexing. If a table has an ID column that is indexed and a name column that is not, finding a row by ID will be MUCH faster.

Primary key and foreign key columns (which often have names starting or ending with "ID") are generally more likely to be indexed since they're frequently used for joins, so it may well be the case that looking up an item by ID will be faster. But to be sure, you need to look at the table definition instead of the name.

Upvotes: 1

Related Questions