~ubuntu-branches/debian/sid/sqlheavy/sid

« back to all changes in this revision

Viewing changes to data/schemas/profiling/Create.sql

  • Committer: Package Import Robot
  • Author(s): Devid Antonio Filoni
  • Date: 2011-10-23 15:43:22 UTC
  • Revision ID: package-import@ubuntu.com-20111023154322-unzj3fz2aj4g6cl8
Tags: upstream-0.1.0
ImportĀ upstreamĀ versionĀ 0.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
CREATE TABLE IF NOT EXISTS `queries` (
 
2
  `sql` TEXT UNIQUE NOT NULL,
 
3
  `executions` INTEGER UNSIGNED DEFAULT 1,
 
4
  `clock` FLOAT UNSIGNED NOT NULL,
 
5
  `fullscan_step` INTEGER UNSIGNED,
 
6
  `sort` INTEGER UNSIGNED
 
7
);
 
8
 
 
9
CREATE TRIGGER IF NOT EXISTS `queries_insert`
 
10
  BEFORE INSERT ON `queries`
 
11
  WHEN (SELECT COUNT(*) FROM `queries` WHERE `sql` = NEW.`sql`) > 0
 
12
  BEGIN
 
13
    UPDATE `queries`
 
14
      SET
 
15
        `executions` = `executions` + 1,
 
16
        `clock` = `clock` + NEW.`clock`,
 
17
        `fullscan_step` = `fullscan_step` + NEW.`fullscan_step`,
 
18
        `sort` = `sort` + NEW.`sort`
 
19
      WHERE `sql` = NEW.`sql`;
 
20
    SELECT RAISE(IGNORE);
 
21
  END;