Optimizer Cost Constants
This section describes the optimizer cost constants. The cost variables described here are measured on an arbitrary scale. Only their relative values matter, therefore scaling them all up or down by the same factor will result in no change in the optimizer's choices. By default, they use the cost of fetching sequential pages as the basic unit. That is, seq_page_cost is set to 1.0 and the other cost variables are set with reference to the parameter. However, you can use a different scale, such as actual execution time in milliseconds.
seq_page_cost
Parameter description: Specifies the optimizer's estimated cost of a disk page fetch that is part of a series of sequential fetches.
Parameter type: floating-point.
Unit: none
Value range: 0 to DBL_MAX
Default value: 1
Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.
Setting suggestion: none
random_page_cost
Parameter description: Specifies the optimizer's estimated cost of an out-of-sequence disk page fetch.
Parameter type: floating-point.
Unit: none
Value range: 0 to DBL_MAX
Default value: 4
Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.
Setting suggestion: none
Although the server allows you to set random_page_cost to a value less than that of seq_page_cost, it is not physically sensitive to do so. However, setting them equal makes sense if the database is entirely cached in RAM, because in that case there is no penalty for fetching pages out of sequence. Also, in a heavily-cached database you should lower both values relative to the CPU parameters, since the cost of fetching a page already in RAM is much smaller than it would normally be.
- This value can be overwritten for tables and indexes in a particular tablespace by setting the tablespace parameter of the same name.
- Reducing this value relative to seq_page_cost will cause the system to prefer index scans and raising it will make index scans relatively more expensive. You can increase or decrease both values together to change the disk I/O costs relative to CPU costs.
cpu_tuple_cost
Parameter description: Specifies the optimizer's estimated cost of processing each row during a query.
Parameter type: floating-point.
Unit: none
Value range: 0 to DBL_MAX
Default value: 0.01
Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.
Setting suggestion: none
cpu_index_tuple_cost
Parameter description: Specifies the optimizer's estimated cost of processing each index entry during an index scan.
Parameter type: floating-point.
Unit: none
Value range: 0 to DBL_MAX
Default value: 0.005
Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.
Setting suggestion: none
cpu_operator_cost
Parameter description: Specifies the optimizer's estimated cost of processing each operator or function executed during a query.
Parameter type: floating-point.
Unit: none
Value range: 0 to DBL_MAX
Default value: 0.0025
Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.
Setting suggestion: none
effective_cache_size
Parameter description: Specifies the optimizer's assumption about the effective size of the disk cache that is available to a single query.
Set this parameter based on the following factors: the GaussDB's shared buffer space, the kernel's disk buffer space, and the estimated number of concurrent queries on different tables that share the available space.
This parameter does not affect the size of the shared memory allocated during actual GaussDB running. It is used only for estimation in the plan generation phase. The value is in the unit of disk page. Usually the size of each page is 8192 bytes.
Parameter type: integer.
Unit: page (8 KB)
Value range:
- Method 1: Set this parameter to an integer without a unit. The integer ranges from 1 to 2147483647. For example, 200 indicates that there are 200 pages, that is, the size of 200 x 8 KB.
- Method 2: Set this parameter to a value with a unit. The value ranges from 1 x 8 KB to 2147483647 x 8 KB. For example, the value 200MB indicates 200 MB. The unit can only be KB, MB, or GB.
Default value:
Independent deployment:
CN: 2GB (60-core CPU/480 GB memory); 1GB (32-core CPU/256 GB memory and 16-core CPU/128 GB memory); 512MB (8-core CPU/64 GB memory); 256MB (4-core CPU/32 GB memory); 128MB (4-core CPU/16 GB memory)
DN: 70GB (60-core CPU/480 GB memory); 38GB (32-core CPU/256 GB memory); 20GB (16-core CPU/128 GB memory); 8GB (8-core CPU/64 GB memory); 4GB (4-core CPU/32 GB memory); 2GB (4-core CPU/16 GB memory)
Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.
Setting suggestion: A larger value indicates that the optimizer prefers index scan, and a smaller value indicates that the optimizer prefers full table scanning. Generally, the value is half of the value of shared_buffers. More radically, you can set the value to three-fourth of the value of shared_buffers. If the memory is sufficient, a larger value indicates better performance.
allocate_mem_cost
Parameter description: Specifies the query optimizer's estimated cost of creating a hash table for memory space using hash join. This parameter is used for optimization when the hash join estimation is inaccurate.
Parameter type: floating-point.
Unit: none
Value range: 0 to DBL_MAX
Default value: 0
Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.
Setting suggestion: none
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot