meter table contains redundant/duplicate data

Bug #1211985 reported by Jay Pipes
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Wishlist
gordon chung

Bug Description

The meter table is one of the base "fact" tables in the Ceilometer schema. As such, the number of rows in this table will be large. We should remove redundant and duplicate fields from this schema to allow many more records per data and index page.

The current (as of 2013-08-13) schema for the meter table looks like this:

CREATE TABLE meter (
  id INT PRIMARY KEY,
  counter_nameVARCHAR(255) NOT NULL,
  user_id VARCHAR(255) NOT NULL,
  project_id VARCHAR(255) NOT NULL,
  resource_id VARCHAR(255) NOT NULL,
  resource_metadata TEXT NOT NULL,
  counter_type VARCHAR(255) NOT NULL,
  counter_unit VARCHAR(255) NOT NULL,
  counter_volume FLOAT NOT NULL,
  timestamp DATETIME NOT NULL DEFAULT NOW(),
  message_signature VARCHAR(1000) NOT NULL,
  message_id VARCHAR(1000) NOT NULL,
  FOREIGN KEY user_id REFERENCES user(id),
  FOREIGN KEY project_id REFERENCES project(id),
  FOREIGN KEY resource_id REFERENCES resource(id),
  INDEX ix_meter_timestamp (timestamp),
  INDEX ix_meter_user_id (user_id),
  INDEX ix_meter_project_id (project_id),
  INDEX 'idx_meter_rid_cname' (resource_id, counter_name)
)

I propose normalizing the database schema in the following ways:

1) Replace counter_type with an integer column counter_type_id that references a lookup table (counter_type)
2) Replace counter_unit with an integer column counter_unit_id that references a lookup table (counter_unit)
3) Replace counter_name with an integer column counter_id that references a lookup table (counter)

The above 3 modifications should dramatically reduce the average row size for records in the meter table and be a good first step in improving query performance...

Julien Danjou (jdanjou)
Changed in ceilometer:
status: New → Triaged
importance: Undecided → Wishlist
Julien Danjou (jdanjou)
Changed in ceilometer:
milestone: none → icehouse-1
Changed in ceilometer:
assignee: nobody → Vladimir Vechkanov (vvechkanov)
Revision history for this message
Vladimir Vechkanov (vvechkanov) wrote :

You propose is good but I think we can make fewer duplication rows if will create databases in such way:

1) Replace counter_type, counter_unit, counter_name with an integer column counter_id that references a lookup table (counter).
2) Create table (counter) with rows:
               * id
               * name
               * type_id (reference to type)
               * unit_name
3) Create table (type) with rows:
               * id
               * name

Reasons:
* We have several counter_types, so they will be meet in a meters very often, so create different table for them.
* We have some same values in counters for different timestamp, user_id, project_id, so create different table for them.

What do you think about this idea?
Anyways I can implement TS proposal if community will decide that it's better.

Revision history for this message
gordon chung (chungg) wrote :

i like the idea of adding sample table with rows:
               * id
               * name
               * type
               * unit_name

i don't know if we need to add a second table for just type seems like overkill but i'm definitely not a db performance expert

Julien Danjou (jdanjou)
Changed in ceilometer:
milestone: icehouse-1 → none
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

Fix proposed to branch: master
Review: https://review.openstack.org/65786

Changed in ceilometer:
assignee: Vladimir Vechkanov (vvechkanov) → gordon chung (chungg)
status: Triaged → In Progress
gordon chung (chungg)
Changed in ceilometer:
milestone: none → icehouse-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/69260

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/65786
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=604fc8258c5c62432058c6410b835537c1bc7be3
Submitter: Jenkins
Branch: master

commit 604fc8258c5c62432058c6410b835537c1bc7be3
Author: Gordon Chung <email address hidden>
Date: Wed Jan 8 14:45:05 2014 -0500

    sample table contains redundant/duplicate data

    create a meter table to store meter definition attributes:
    - name
    - type
    - unit

    blueprint: meter-table-sql
    Closes-Bug: #1211985
    Change-Id: I4dd510e66d64226b03cfce8d7dd5e77937793ba3

Changed in ceilometer:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in ceilometer:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: icehouse-3 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.