exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

benchmark-0001.sql (1692B)


      1 --
      2 -- This file is part of TALER
      3 -- Copyright (C) 2014--2021 Taler Systems SA
      4 --
      5 -- TALER is free software; you can redistribute it and/or modify it under the
      6 -- terms of the GNU General Public License as published by the Free Software
      7 -- Foundation; either version 3, or (at your option) any later version.
      8 --
      9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11 -- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 --
     13 -- You should have received a copy of the GNU General Public License along with
     14 -- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 --
     16 
     17 -- Everything in one big transaction
     18 BEGIN;
     19 
     20 -- Check patch versioning is in place.
     21 SELECT _v.register_patch('benchmark-0001', NULL, NULL);
     22 
     23 -- Naive, btree version
     24 CREATE TABLE IF NOT EXISTS benchmap
     25   (uuid BIGSERIAL PRIMARY KEY
     26   ,hc BYTEA UNIQUE CHECK(LENGTH(hc)=64)
     27   ,expiration_date INT8 NOT NULL
     28   );
     29 
     30 -- Replace btree with hash-based index
     31 CREATE TABLE IF NOT EXISTS benchhmap
     32   (uuid BIGSERIAL PRIMARY KEY
     33   ,hc BYTEA NOT NULL CHECK(LENGTH(hc)=64)
     34   ,expiration_date INT8 NOT NULL
     35   );
     36 CREATE INDEX IF NOT EXISTS benchhmap_index
     37   ON benchhmap
     38   USING HASH (hc);
     39 ALTER TABLE benchhmap
     40   ADD CONSTRAINT pk
     41   EXCLUDE USING HASH (hc with =);
     42 
     43 -- Keep btree, also add 32-bit hash-based index on top
     44 CREATE TABLE IF NOT EXISTS benchemap
     45   (uuid BIGSERIAL PRIMARY KEY
     46   ,ihc INT4 NOT NULL
     47   ,hc BYTEA UNIQUE CHECK(LENGTH(hc)=64)
     48   ,expiration_date INT8 NOT NULL
     49   );
     50 CREATE INDEX IF NOT EXISTS benchemap_index
     51   ON benchemap
     52   USING HASH (ihc);
     53 
     54 -- Complete transaction
     55 COMMIT;