log4j2.xml
to enable query execution tracing. Here's how you can do it: log4j2.xml
file, which is typically located in the config
directory of your GemFire installation.<Logger name="org.apache.geode.cache.query.internal.DefaultQuery" level="trace" additivity="false"> <AppenderRef ref="Console"/> </Logger>
TRACE
for the org.apache.geode.cache.query.internal.DefaultQuery
class, which handles query execution in GemFire. The log messages will be sent to the console appender.
After making these changes, GemFire will start logging query execution traces to the specified appender. You will see detailed information about the executed queries, including the query text, execution time, and index usage.
Keep in mind that TRACE-level logging can generate a significant amount of log data, so use it judiciously and only for debugging or diagnostic purposes. Make sure to revert the log level to an appropriate level (e.g., INFO or DEBUG) in a production environment to avoid performance impact due to excessive logging.
[info 2023/07/19 10:00:00.000 UTC <GemFire Server Query Execution Thread> tid=0x1] Executing query: SELECT * FROM /regionName WHERE field1 = 'value' [trace 2023/07/19 10:00:00.001 UTC <GemFire Server Query Execution Thread> tid=0x1] Query execution time: 2 ms [trace 2023/07/19 10:00:00.001 UTC <GemFire Server Query Execution Thread> tid=0x1] Using index: field1_index for query: SELECT * FROM /regionName WHERE field1 = 'value'
IndexStats
: This MBean provides various statistics related to an index, including the number of times the index has been used, the number of keys it contains, and more. You can use the getNumUses()
method to get the number of times the index has been utilized to accelerate queries.IndexMBean
: This MBean allows you to manage indexes, including creating, destroying, and rebalancing indexes. You can use the createIndex()
method to create a new index programmatically or through JMX.RegionIndexStats
: This MBean provides statistics for all the indexes in a specific region. You can use the getIndexStats()
method to get the statistics for all indexes in the region.IndexMetadata
: This MBean provides metadata information for an index, such as the index name, region name, indexed expression, and more. You can use the getIndexName()
and getIndexedExpression()
methods to retrieve information about a specific index.gfsh>list indexes --with-stats=true