Quantcast
Channel: Planet PostgreSQL
Viewing all articles
Browse latest Browse all 9654

Bruce Momjian: The Externality of Index Creation

$
0
0

Suppose a manufacturer produces a product and makes a profit, yet manufacturing generates greater social harm than the value of the product. How does the manufacturer stay in business? Because the manufacturing costs are distributed among many people and are not all paid by the company. This is called an external cost or externality and is commonly seen with pollution costs or natural resource depletion. It can also apply to database index creation.

Huh? Database index creation? Yes. Consider this case: you are troubleshooting a query; it is slow. It is slow because there is no index matching the query qualification, so you add one. The query is now much faster, so you are done. But are you? Your query is faster, but what about other queries? What about insert and some update operations? They now have to update that index you created — that has to take some time. How much? It is hard to measure, because it is distributed among many queries, and is probably small compared to the speed-up you saw in the query that prompted the index creation. But a lot of small slowdowns can easily surpass the speed-up you saw in that one query.

How can your measure all those small slowdowns? I don't know, but do know they exist, so be careful adding an index that has limited use — you might find that externalities make your system slower.


Viewing all articles
Browse latest Browse all 9654

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>