Questions tagged [cost-based-optimizer]

CBO or Cost-Based-Optimization is a collection of techniques within a RDBMS designed to evaluate numerically how expensive a SQL statement will be. Any SQL statement can be executed in different ways. Each of these ways is a possible execution plan. The CBO will assign to each plan a cost which represents a numeric evaluation of how expensive the operation will be. It will always select the plan with the lowest cost. Lowest cost in this regard logically represents the lowest elapsed time to execute such query.

For a CBO to work properly, statistics are necessary and should be maintained regularly. Oracle , Postgres, MySQL, etc are examples of RDBMS which use the CBO method to evaluate the best way to execute SQL statements.

Use this tag for questions related to execution plans of queries based on the CBO method.

75 questions
0
votes
1 answer

Oracle to_date() difference in plan and time execution

i have two queries select * from T where DATE_OF between to_date ('01.02.2012 00:00:00', 'DD.MM.YYYY hh24:mi:ss') and to_date ('01.02.2012 23:59:59','DD.MM.YYYY hh24:mi:ss') explain plan SELECT STATEMENT ALL_ROWSCost: 146,313 …
turbanoff
  • 2,439
  • 6
  • 42
  • 99
0
votes
0 answers

How can we use costcla package if we have installed python v3.9.7 ? If I degrade python to v3.5 then I hav to change version of tf, cuda and cudnn too

I am working on LSTM model and using cuda and cudnn in tensorflow. CUDA version is 11.2, cuDNN version is 8.1, tf version is 2.5 and python version is 3.9. I have to use costcla library of PyPi but it is compatible with python v3.5. How can I use…
0
votes
1 answer

How does MySQL calculated a query cost?

I have this query: explain format=json select count(*) from info2 -- force index(idx_02) where order_code = '1027' and issue = '20220720' and state = 0 ; Actually choose idx_02 is better than idx_01 ,but MySQL choose id_01. Look at the two…
linlowa
  • 13
  • 1
  • 5
0
votes
1 answer

How to add costs to routes in Anylogic?

I am creating a model in Anylogic to simulate the container transportation between a port and the hinterland (in a GIS map). I have data on how many trucks are driving between each customer zone and the terminals. I want to add a possible hub in the…
0
votes
1 answer

Piecewise linear programming in CPLEX

I have a problem in building the expression for transportation costs in CPLEX. In particular, it is a piecewise linear function of the flow of material, reflecting economies of scale. Consider the transportation cost from Plant to Warehouse, we…
0
votes
0 answers

Resource Allocation Algorithms - Minimize cost given Time

I want assign tasks to workers in a way that cost is minimized given a time constraint. Suppose: Labor Cost: $20/hr and handles 10Kg Machine Cost: $30/hr and handles 20Kg and requires a Machine Operator Machine Operator Cost:…
Lopez
  • 461
  • 5
  • 19
0
votes
1 answer

How to assign each task to every crew so for a better cost optimization?

I had few data about tasks showing about every task and how long the task is, for e.g.: Table 1: Tasks Length Time Task 1 45 mins 6:30 Task 2 45 mins 7:00 Here I know about every task, how long the task is, and at what time the task is…
0
votes
1 answer

MySql Query optimizer

If I have a query like this select * from student inner join courses on courses.id = student.course_id where student.gpa >= 3.0 order by student.gpa limit 50; How would Mysql execute this query to optimize the cost?
0
votes
1 answer

Monitoring Cpu, iops and memory on Azure

I want to monitor the cpu/iops/memory usage for my appliation in an azure vm. I need to run it different times for different families to chose the best fit for my app. Should I use Azure monitor or a cli app inside my VM? Which are the best tools to…
0
votes
0 answers

Algorithm to distribute N unequally sized rectangles while maintaining an aspect ratio

I want to distribute n rectangles from a dataframe with different heights and lengths so that the aspect ratio (r_expected) of the total length (L) and total height (H) is roughly L/H = 0.33. A sketch of the rectangle distribution logic below: To…
0
votes
0 answers

Cost: calling if vs calling function

I am trying to come up with an optimized solution where I need to loop through 1000's of records in an excel sheet. I have scenarios like: if (!lei.renewalDate) { lei.renewalDate = new Date(record.renewalDate).getTime(); } if…
Pritam Bohra
  • 3,912
  • 8
  • 41
  • 72
0
votes
0 answers

Maximize sum of subset of arrays under given cost

I have an array of n Objects with an int 'value' and another int 'cost'. I want to get the subset of size k (k < n) of that array that maximizes the sum of the values. For instance... Value - Cost 32 - 24 25 - 17 39 - 40 10 - 10 47 - 44 0 - 10 18 -…
0
votes
0 answers

Allocation minimum cost with quantity constraint in Python

I'm trying to solve an allocation problem: I have 350 000 parcels with size S_i, each parcel can only have a state, and for each parcel I have a set of probability for each state, I have a quantity to reach I found the Vogel approximation method…
0
votes
1 answer

Spark SQL reading parquet tables and csv tables differently

I have two external tables created in the spark-sql. One has a file format of parquet and other one has file format as textfile. When we extract query plan on these two table, spark treats the two tables differently. The output of query plan on…
Rajat Mishra
  • 3,635
  • 4
  • 27
  • 41
0
votes
1 answer

Why Query Cost is So different for same type of Query?

Here is my SQL query in SQL Server 2008. Three identical queries, with different approaches Declare @UploadDetailID nvarchar(500) =…