Bug 1402397

Summary: [scale] - DWH use unamed and non-optimized query.
Product: [oVirt] ovirt-engine-dwh Reporter: Eldad Marciano <emarcian>
Component: DatabaseAssignee: Shirly Radco <sradco>
Status: CLOSED NOTABUG QA Contact: Pavel Stehlik <pstehlik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.0.6CC: bugs, emarcian, oourfali
Target Milestone: ovirt-4.0.7Flags: sradco: ovirt-4.0.z?
sradco: planning_ack?
sradco: devel_ack?
sradco: testing_ack?
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-12 12:10:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Metrics RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Eldad Marciano 2016-12-07 13:00:02 UTC
Description of problem:
there is unnamed query which runs a lot and hit the performance.
this query found when running CFME with RHV.

LOG:  duration: 3059.466 ms  execute <unnamed>: SELECT
          history_id,
          history_datetime,
          current_user_id,
          current_user_name,
          cast(user_logged_in_to_guest as int),
          vm_id,
          seconds_in_status,
          cpu_usage_percent,
          memory_usage_percent,
          user_cpu_usage_percent,
          system_cpu_usage_percent,
          vm_ip,
          vm_client_ip,
          currently_running_on_host,
          vm_configuration_version,
          current_host_configuration_version
        FROM vm_samples_history
        WHERE vm_status = 1
        AND history_datetime >= '2016-12-04 22:00:00.000000+0000'
        AND history_datetime < '2016-12-04 23:00:00.000000+0000'
        ORDER BY history_datetime,
                 current_user_name,
                 vm_id



Version-Release number of selected component (if applicable):
4.0.6.1

How reproducible:
100%

Steps to Reproduce:
1. scale out lab with 27 hosts and 2.2K vms
2.
3.

Actual results:
non-optimized query 

Expected results:
optimized query.

Additional info:

Comment 1 Shirly Radco 2016-12-11 07:42:38 UTC
This query rum every hour. Unless for some reason there was an issue with aggregation and it is now running to catch up to the hour before last.

Comment 2 Eldad Marciano 2016-12-11 09:47:36 UTC
(In reply to Shirly Radco from comment #1)
> This query rum every hour. Unless for some reason there was an issue with
> aggregation and it is now running to catch up to the hour before last.

any chance it caused by https://bugzilla.redhat.com/show_bug.cgi?id=1402471 ?!

Comment 3 Yaniv Kaul 2016-12-12 12:10:12 UTC
For all we know, this is NOTABUG. Closing as such.
Eldad - please re-open properly, with all information.

Comment 4 Eldad Marciano 2016-12-12 12:30:47 UTC
(In reply to Yaniv Kaul from comment #3)
> For all we know, this is NOTABUG. Closing as such.
> Eldad - please re-open properly, with all information.

This bug caused by missing index's, somehow we can't find them on the relevant table "vm_samples_history" 

fixing it by re-running the crate_tables.sql script.

im not sure, but I suspect that something was failed on the upgrade process.
we'll update \ submit a new bug for it.