Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I speed up queries against tables I cannot add indexes to?

I access several tables remotely via DB Link. They are very normalized and the data in each is effective-dated. Of the millions of records in each table, only a subset of ~50k are current records.

The tables are internally managed by a commercial product that will throw a huge fit if I add indexes or make alterations to its tables in any way.

What are my options for speeding up access to these tables?

like image 612
aw crud Avatar asked Mar 23 '10 14:03

aw crud


People also ask

Can adding an index slow down a query?

Having two identical indexes makes a negative impact on the performance of SQL queries. It is actually a waste of disk space and also slows down the insertions to the table. Therefore, it is a good practice to avoid duplicate indexes to eliminate these issues.

Do indexes speed up queries?

Indexing makes columns faster to query by creating pointers to where data is stored within a database. Imagine you want to find a piece of information that is within a large database. To get this information out of the database the computer will look through every row until it finds it.


2 Answers

You could try to create a materialized view of some subset of the tables over the DB link and then query from those.

like image 69
carson Avatar answered Oct 13 '22 19:10

carson


I think you're stuck between a rock and a hard place here, but in the past the following has worked for me:

You can pull down a snapshot of the current data at specified intervals, every hour or nightly or whatever works, and add your indexes to your own tables as needed. If you need realtime access the data, then you can try pulling all the current records into a temp table and indexing as needed.

The extra overhead of copying from one database into your own may dwarf the actual benefit, but its worth a shot.

like image 24
Juliet Avatar answered Oct 13 '22 18:10

Juliet