Query layers are an integration method that allows ArcGIS to connect to relational databases as data sources using direct SQL queries rather than connecting through an enterprise geodatabase. Query layers are a general concept that allow for access and display of tabular data from various database sources, which may or may not include spatial data, but which can be read directly from that source without need for an ETL process or data load through other methods.
Query layers provide a flexible method to work with these database systems, and allow ArcGIS to integrate with other business systems and data storage offerings for primarily read-only use cases. Under certain conditions, query layers can be made editable by publishing them into a feature access-enabled map service to create a feature service.
Query layers have two primary use patterns: Authoring and use in ArcGIS Pro, and publishing to ArcGIS Enterprise to use with ArcGIS clients. The sequential steps involved in both use patterns are similar.
The first step in authoring a query layer is the design process – what goal is the query layer designed to accomplish, and how can that be achieved efficiently and effectively? This process can be carried out with the support of data analysts, architects or database administration professionals inside your organization.
The main goal is to define a SQL query that returns data quickly, returns an appropriate and concise set of columns and rows, and includes data types for columns that are compatible with ArcGIS. Database administrators can also assist with patterns like materialized views, which can dramatically improve the query performance from ArcGIS to a complex view, such as one that includes many joins. Importantly, ensure that the query returns a column that contains unique, consistent values for each row in the query result. This uniqueness is required for ArcGIS to work with the query.
The second step to work with query layers is to create a database connection to the system storing the source data. The supported databases for query layers are defined in the ArcGIS Pro documentation, and include all of the databases used to host an enterprise geodatabase along with other options like cloud data warehouses or document databases. The database connection process includes an authentication step which supports specific scenarios, so be sure that your database supports standard database authentication to enable query layer access. Other authentication methods may be supported but should be carefully validated with ArcGIS documentation.
The third step is to create the query layer in ArcGIS Pro, using the Add Query Layer interface. In this dialog, provide the previously-developed SQL query and specify which column to use as a unique identifier. If a spatial column is returned, the interface will prompt for a spatial reference definition. After completion, the layer should load to the active map. Be careful with layers that contain many results as they may result in slow draw times if the SQL query is complex or requires searching across many source tables. See other best practices for query layer creation in the ArcGIS Pro documentation.
Once the query layer definition is complete and the layer is added to the map, it can be visualized and worked with like any other layer in ArcGIS Pro. Query layers can be symbolized, can have popups defined, and can be used as a source for analytical tools, exported to print products, or used to create vector tile layer outputs. Query layers are persisted when a Map is saved with a Project, and any user that opens that map will be able to see the same information as long as they have network access to the same database and the .sde file is persisted.
Optionally, query layers can also be published to ArcGIS Enterprise to create a map image layer, also known as a map service. This process follows standard publishing patterns with ArcGIS Enterprise and requires data store registration, cartographic design, and overall map service design processes just like other map services. There are also some specific considerations for query layers published from cloud data warehouses related to performance and caching.
| Capability | ArcGIS Online | ArcGIS Enterprise | ArcGIS Location Platform | ArcGIS Pro |
|---|---|---|---|---|
| Query layer support | N/A |
Full support
Partial support
Query layers published to ArcGIS Enterprise as map image layers can be consumed in ArcGIS Online applications, but be aware of cross-system authentication patterns and ensure access is managed correctly.
Query layers can be used to meet a wide variety of business requirements, especially within environments where multiple departments or groups use similar database technologies deployed within the same network. Some representative examples of using query layers in geospatial systems are provided below: