Berkof commented on a change in pull request #9550: URL: https://github.com/apache/ignite/pull/9550#discussion_r744468654
########## File path: docs/_docs/SQL/sql-statistics.adoc ########## @@ -0,0 +1,182 @@ +// 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. += SQL Statistics + +== Overview + +Apache Ignite can calculate statistics by request and use it to build an optimal SQL query plan. This enables you to significantly speed up the SQL query execution. + +Without statistics, SQL query execution planner tries to guess about the query conditions selectivity using only general heuristics. To get better plans, make sure that statistics usage is link:tools/control-script#working-with-cluster-properties[enabled,window=_blank] and link:sql-reference/ddl#analyze[configure statistics collection,window=_blank] for tables participated in the query. See the link:SQL/sql-statistics#obtaining-a-better-execution-plan-using-statistics[example] for more details. + +Statistics are checked and updated each time after one of the following actions: + +* Node start +* Topology change +* Configuration change + +A node checks partitions and collects statistics for each of them, which can be used in SQL query optimization. + +== Configuring Statistics + +By default, statistics functionality is enabled. + +Statistics are stored locally, while statistics configuration parameters are stored cluster-wide. + +To enable or disable statistics in cluster use, execute the following command, specifying `ON`, `OFF`, or `NO_UPDATE` values: + +[tabs] +-- +tab:Unix[] +[source,shell] +---- +control.sh --property set --name 'statistics.usage.state' --val 'ON' +---- +tab:Windows[] +[source,shell] +---- +control.bat --property set --name 'statistics.usage.state' --val 'ON' +---- +-- + +To see the statistics usage state, execute the command below: + +[tabs] +-- +tab:Unix[] +[source,shell] +---- +control.sh --property get --name 'statistics.usage.state' +---- +tab:Windows[] +[source,shell] +---- +control.bat --property get --name 'statistics.usage.state' +---- +-- + +For more details on configuring SQL statistics, see the link:monitoring-metrics/system-views[System Views,window=_blank] and link:sql-reference/ddl[Data Definition Language,window=_blank] pages. Review comment: Better to open one of statistics views, like: /docs/monitoring-metrics/system-views#statistics_configuration and one of statistics related DDL commnds, like: /docs/sql-reference/ddl#analyze ########## File path: docs/_docs/SQL/sql-statistics.adoc ########## @@ -0,0 +1,182 @@ +// 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. += SQL Statistics + +== Overview + +Apache Ignite can calculate statistics by request and use it to build an optimal SQL query plan. This enables you to significantly speed up the SQL query execution. + +Without statistics, SQL query execution planner tries to guess about the query conditions selectivity using only general heuristics. To get better plans, make sure that statistics usage is link:tools/control-script#working-with-cluster-properties[enabled,window=_blank] and link:sql-reference/ddl#analyze[configure statistics collection,window=_blank] for tables participated in the query. See the link:SQL/sql-statistics#obtaining-a-better-execution-plan-using-statistics[example] for more details. + +Statistics are checked and updated each time after one of the following actions: + +* Node start +* Topology change +* Configuration change + +A node checks partitions and collects statistics for each of them, which can be used in SQL query optimization. + +== Configuring Statistics + +By default, statistics functionality is enabled. + +Statistics are stored locally, while statistics configuration parameters are stored cluster-wide. + +To enable or disable statistics in cluster use, execute the following command, specifying `ON`, `OFF`, or `NO_UPDATE` values: + +[tabs] +-- +tab:Unix[] +[source,shell] +---- +control.sh --property set --name 'statistics.usage.state' --val 'ON' +---- +tab:Windows[] +[source,shell] +---- +control.bat --property set --name 'statistics.usage.state' --val 'ON' +---- +-- + +To see the statistics usage state, execute the command below: + +[tabs] +-- +tab:Unix[] +[source,shell] +---- +control.sh --property get --name 'statistics.usage.state' +---- +tab:Windows[] +[source,shell] +---- +control.bat --property get --name 'statistics.usage.state' +---- +-- + +For more details on configuring SQL statistics, see the link:monitoring-metrics/system-views[System Views,window=_blank] and link:sql-reference/ddl[Data Definition Language,window=_blank] pages. + +== Statistics Overriding + +Gathered values can be overridden by specifying additional parameters in the link:sql-reference/ddl#analyze[ANALYZE,window=_blank] command. The specified values override gathered one on each node in link:monitoring-metrics/system-views#statistics_local_data[STATISTICS_LOCAL_DATA,window=_blank], but not in link:monitoring-metrics/system-views#statistics_partition_data[STATISTICS_PARTITION_DATA,window=_blank]. Then, overriden values are used by SQL query optimizer. Review comment: It's correct, that overriding affects statistics_local_data, but not statistics_partition_data. But it is not clear that SQL optimizer will use data from statistics_local_data and it can confuse newbie user if "overrides" changes SQL optimizer behaviour totally as real statistics or just partially. Can we make it more obvious? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
