blob: 1bc7ac7f3bff0f4f08829c9d225a39eea2011110 [file] [log] [blame]
---
title: Working with Indexes
---
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
The <%=vars.product_name%> query engine supports indexing. An index can provide significant performance gains for query execution.
<a id="indexing__section_565C080FBDD0443C8504DF372E3C32C8"></a>
A query run without the aid of an index iterates through every object in the collection. If an index is available that matches part or all of the query specification, the query iterates only over the indexed set, and query processing time can be reduced.
- **[Tips and Guidelines on Using Indexes](indexing_guidelines.html)**
Optimizing your queries with indexes requires a cycle of careful planning, testing, and tuning. Poorly-defined indexes can degrade the performance of your queries instead of improving it. This section gives guidelines for index usage in the query service.
- **[Creating, Listing and Removing Indexes](creating_an_index.html)**
The <%=vars.product_name%> `QueryService` API provides methods to create, list and remove the index. You can also use `gfsh` command-line interface to create, list and remove indexes, and use cache.xml to create an index.
- **[Creating Key Indexes](creating_key_indexes.html)**
Creating a key index is a good way to improve query performance when data is partitioned using a key or a field value. You can create key indexes by using the `createKeyIndex` method of the QueryService or by defining the index in `cache.xml`. Creating a key index makes the query service aware of the relationship between the values in the region and the keys in the region.
- **[Creating Hash Indexes](creating_hash_indexes.html)**
**Hash indexes are deprecated.** <%=vars.product_name%> supports the creation of hash indexes for the purposes of performing equality-based queries.
- **[Creating Indexes on Map Fields ("Map Indexes")](creating_map_indexes.html)**
To assist with the quick lookup of multiple values in a Map (or HashMap) type field, you can create an index (sometimes referred to as a "map index") on specific (or all) keys in that field.
- **[Creating Multiple Indexes at Once](create_multiple_indexes.html)**
In order to speed and promote efficiency when creating indexes, you can define multiple indexes and then create them all at once.
- **[Maintaining Indexes (Synchronously or Asynchronously) and Index Storage](maintaining_indexes.html)**
Indexes are automatically kept current with the region data they reference. The region attribute `IndexMaintenanceSynchronous` specifies whether the region indexes are updated synchronously when a region is modified or asynchronously in a background thread.
- **[Using Query Index Hints](query_index_hints.html)**
You can use the hint keyword to allow <%=vars.product_name%>'s query engine to prefer certain indexes.
- **[Using Indexes on Single Region Queries](indexes_on_single_region_queries.html)**
Queries with one comparison operation may be improved with either a key or range index, depending on whether the attribute being compared is also the primary key.
- **[Using Indexes with Equi-Join Queries](using_indexes_with_equijoin_queries.html)**
Equi-join queries are queries in which two regions are joined through an equality condition in the WHERE clause.
- **[Using Indexes with Overflow Regions](indexes_with_overflow_regions.html)**
You can use indexes when querying on overflow regions; however, there are caveats.
- **[Using Indexes on Equi-Join Queries using Multiple Regions](using_indexes_with_equijoin_queries_multiple_regions.html)**
To query across multiple regions, identify all equi-join conditions. Then, create as few indexes for the equi-join conditions as you can while still joining all regions.
- **[Index Samples](index_samples.html)**
This topic provides code samples for creating query indexes.