Databases with utilization constraints
I have a web-based application that allows users to create their own complicated queries using a simplified scripting language and GUI. Problem is - sometimes my users are well, not so bright. Often, they'll create a query that does massive joins, or employs pointless comparisons over large datasets that quickly consumes most of the available resources on the machine. In effect, a small amount of folks are ruining the party for everyone else. Training or banning these "special" users isn't an option.
So here's my question: Are there any databases (NoSQL or SQL, or anything really) that support resource constraints on a per query basis?
Limiting CPU utilization would be bare minimum, b开发者_JAVA百科ut other constraints like execution time, memory usage and rows-returned limits would be nice too. It'd be especially handy if I could programmatically specify limits so I could target my problem users.
EDIT: Extra points for opensource and/or free products.
EDIT2: Found some related questions, that make it clear that Oracle supports some sort of resource-limiting scheme, but are there any other products that do? Just Oracle and SQL Server?
https://serverfault.com/questions/124158/throttle-or-limit-resources-used-by-a-user-in-a-database Is there a way to throttle or limit resources used by a user in Oracle?
SQL Server 2008 supports a resource governor:
Resource Governor is a new technology in SQL Server 2008 that enables you to manage SQL Server workload and resources by specifying limits on resource consumption by incoming requests. In the Resource Governor context, workload is a set of similarly sized queries or requests that can, and should be, treated as a single entity. This is not a requirement, but the more uniform the resource usage pattern of a workload is, the more benefit you are likely to derive from Resource Governor. Resource limits can be reconfigured in real time with minimal impact on workloads that are executing.
Resource Governor provides:
The ability to classify incoming connections and route their workloads to a specific group.
The ability to monitor resource usage for each workload in a group.
The ability to pool resources and set pool-specific limits on CPU usage and memory allocation. This prevents or minimizes the probability of run-away queries.
The ability to associate grouped workloads with a specific pool of resources.
The ability to identify and set priorities for workloads.
Ref.
Resource constraints may ease your problem, but I think that the problem behine the situation is the unpredictable usage of resources.
When database is executing queries, database need to load data into memory and lock resources to maintain the consistent of status. Whatever the constraint system can do, the unpredictable behavior in internal mechanism of database is the most risky thing you should concern.
If I'm facing this kind of situation, I would try to figure out what the user really need and provide more precise query(in some table, or some conditions of data) for it.
If nothing can do, however, I would try to clone(replication) the database for heavy-used user.
精彩评论