A query handling device in a federated database system, the query handling device being configured to receive database queries (Q1, Q2, Q3, Q4) directed towards a group of databases (22, 24, 26, 28) of different type from several applications (A1, A2, A3, A4) running in querying devices (12, 14, 16, 18), the query handling device comprising: - an initiation module configured to assign, at application deployment, each of the applications to the most optimum data-store of data-stores of said databases after analysing the data and queries of the application, - a ranking unit configured to rank the applications, - a query scheduler module comprising a clustering unit configured to cluster database queries based on query execution time and to assign cluster priorities to the clusters based on the query execution times of the queries of the cluster, where the cluster with queries having the shortest query execution time is assigned the highest cluster priority and the cluster with queries having the longest execution time is assigned the lowest cluster priority, the clusters being stored for prioritising future database queries, - a query interface configured to receive the database queries, - a query handling evaluation module configured to investigate the processing capability of system elements of the assigned data-stores, the system elements handling database queries of an application, compare the processing capability with a capability criterion, and inform the query scheduler module of the result, wherein the query scheduler module is further configured to allow the database query to be immediately sent to the assigned data-store and immediately performed if the capability criterion is fulfilled and otherwise to match the database query to the most similar one of the stored clusters by determination of the respective similarity of the database query to the different stored clusters and to assign a query priority to the database query based on the assigned cluster priority of the most similar cluster, and - a selection unit configured to select database queries for execution based on respective assigned query priority and application rank and to send the selected database queries to the assigned data-store. - an initiation module configured to assign, at application deployment, each of the applications to the most optimum data-store of data-stores of said databases after analysing the data and queries of the application, - a ranking unit configured to rank the applications, - a query scheduler module comprising a clustering unit configured to cluster database queries based on query execution time and to assign cluster priorities to the clusters based on the query execution times of the queries of the cluster, where the cluster with queries having the shortest query execution time is assigned the highest cluster priority and the cluster with queries having the longest execution time is assigned the lowest cluster priority, the clusters being stored for prioritising future database queries, - a query interface configured to receive the database queries, - a query handling evaluation module configured to investigate the processing capability of system elements of the assigned data-stores, the system elements handling database queries of an application, compare the processing capability with a capability criterion, and inform the query scheduler module of the result, wherein the query scheduler module is further configured to allow the database query to be immediately sent to the assigned data-store and immediately performed if the capability criterion is fulfilled and otherwise to match the database query to the most similar one of the stored clusters by determination of the respective similarity of the database query to the different stored clusters and to assign a query priority to the database query based on the assigned cluster priority of the most similar cluster, and - a selection unit configured to select database queries for execution based on respective assigned query priority and application rank and to send the selected database queries to the assigned data-store.