Question

Suppose I have many tables in a database that need to be joined together to get a single consistent view of the entire entity graph. Am I forced to do this as a single query? I don't care about locks, I just want to ensure the graph is consistent as of the time of the query execution.

My concern is one of performance of joining a large number of entities together in a single query. Is it possible to do this in multiple queries but still realize the same level of consistency as having performed these individual selects as a single query?

Was it helpful?

Solution

Is it possible to do this in multiple queries but still realize the same level of consistency as having performed these individual selects as a single query?

It depends on the RDBMS.

In SQL Server you can use a transaction with SNAPSHOT transaction isolation level to get a consistent view of the database across multiple queries.

The isolation level Oracle calls SERIALIZABLE does the same thing.

My concern is one of performance of joining a large number of entities together in a single query

This is a valid concern because most RDBMS engines only return tabular results from queries. The strategies to generate a single tabular result for a complex object graph can lead to large resultsets and complex queries. This has always been a problem for ORMs.

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