Question

So I'm working on a Rails project and I have a legacy database, that is used by other applications, hence its structure cannot be modified. The problem is that table and column names do not follow the Rails conventions. A common solution to that is to create MySQL views that just alias columns properly.

These are dead simple views that just have

SELECT old_column_1 AS new_column_1, old_column_2 AS new_column_2 FROM table_name;

Some tables are really big, like 22 million rows (2GiB). All the tables are MYISAM. Also there's one MEMORY table with 2 million rows (~350MiB)

The key question is how much of an overhead do I get with such views and does it in any way impact ROW LOCK or TABLE LOCK during INSERTs or JOINs?

Was it helpful?

Solution

YMMV. Views sometimes fail to do the same optimizations, leading to slower execution than performing the SELECT directly. Since your case is straight forward, probably you will incur no noticeable overhead.

INSERTs through a VIEW have limitations; sounds like you won't hit them. Read the manual.

JOINs is a place where the optimizer may drop the ball; suggest you experiment offline with that, before committing to make the change.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top