PostgreSQLhstore Column Performance Improvement case

Source: Internet
Author: User
PostgreSQL supports hstore to store KEY-gt; VALUE data, which is similar to ARRAY or JSON. To use such data efficiently, of course, efficiency is essential.

PostgreSQL supports hstore to store KEY-gt; VALUE data, which is similar to ARRAY or JSON. To use such data efficiently, of course, efficiency is essential.

PostgreSQL supports hstore to store data such as KEY-> VALUE, which is also similar to ARRAY or JSON. To use this type of data efficiently, you must use efficient indexes. Let's take a look at the performance of two different types of indexes for the same retrieval request.

Suppose we have an original table with a BTREE index based on the str1 field.

T_girl = # \ d status_check;
Table "ytt. status_check"
Column | Type | Modifiers
-------- + --------------------- + -----------
Is_yes | boolean | not null
Str1 | character varying (20) | not null
Str2 | character varying (20) | not null
Indexes:
"Index_status_check_str1" btree (str1)

There are 10 million records. The data is roughly as follows,

T_girl = # select * from status_check limit 2;
Is_yes | str1 | str2
-------- + ------ + ----------------------
F | 0 | cfcd208495d565ef66e7
T | 1 | c4ca4238a0b923820dcc
(2 rows)


Time: 0.617 MS
T_girl = #

Stores the status_check_hstore table structure of the hstore type. There is a GIST index based on the str1_str2 field.

Table "ytt. status_check_hstore"
Column | Type | Modifiers
----------- + --------- + -----------
Is_yes | boolean |
Str1_str2 | hstore |
Indexes:
"Idx_str_str2_gist" gist (strw.str2)

T_girl = # select * from status_check_hstore limit 2;
Is_yes | str1_str2
-------- + -----------------------------
F | "0" => "cfcd208495d565ef66e7"
T | "1" => "c4ca4238a0b923820dcc"
(2 rows)


Time: 39.874 MS

For more details, please continue to read the highlights on the next page:

------------------------------------ Lili split line ------------------------------------

Install PostgreSQL 6.3 on yum in CentOS 9.3

PostgreSQL cache details

Compiling PostgreSQL on Windows

Configuration and installation of LAPP (Linux + Apache + PostgreSQL + PHP) Environment in Ubuntu

Install and configure phppgAdmin on Ubuntu

Install PostgreSQL9.3 on CentOS

Configure a Streaming Replication cluster in PostgreSQL

------------------------------------ Lili split line ------------------------------------

PostgreSQL details: click here
PostgreSQL: click here

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.