磨砺技术珠矶,践行数据之道,追求卓越价值
回到上一级页面:PostgreSQL基础知识与基本操作索引页    回到顶级页面:PostgreSQL索引页[作者 高健@博客园  luckyjackgao@gmail.com]

由于数据少,执行计划中没有使用Index Scan

postgres=# CREATE TABLE items (
postgres(# itemid serial NOT NULL PRIMARY KEY,
postgres(# itemname text NOT NULL,
postgres(# tags hstore);
NOTICE: CREATE TABLE will create implicit sequence "items_itemid_seq" for serial column "items.itemid"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "items_pkey" for table "items"
CREATE TABLE
postgres=#
postgres=# INSERT INTO items (itemname, tags) VALUES ('item1', 'color => red, category => stuff');
INSERT 0 1
postgres=#
postgres=# INSERT INTO items (itemname, tags) VALUES ('item2', 'color => green, category => manager');
INSERT 0 1
postgres=#
postgres=# CREATE INDEX hstoreidx ON items USING gist(tags);
CREATE INDEX
postgres=#
postgres=# SELECT itemname FROM items WHERE tags @> 'color=>red';
itemname
----------
item1
(1 row) postgres=# SELECT itemname FROM items WHERE tags @> 'color=>green';
itemname
----------
item2
(1 row) postgres=# SELECT itemname FROM items WHERE tags @> 'color=>blue';
itemname
----------
(0 rows) postgres=# EXPLAIN SELECT itemname FROM items WHERE tags @> 'color=>red';
QUERY PLAN
------------------------------------------------------
Seq Scan on items (cost=0.00..1.02 rows=1 width=32)
Filter: (tags @> '"color"=>"red"'::hstore)
(2 rows) postgres=#
postgres=# SELECT itemname FROM items WHERE tags ? 'color';
itemname
----------
item1
item2
(2 rows) postgres=# EXPLAIN SELECT itemname FROM items WHERE tags ? 'color';
QUERY PLAN
------------------------------------------------------
Seq Scan on items (cost=0.00..1.02 rows=1 width=32)
Filter: (tags ? 'color'::text)
(2 rows) postgres=#

[作者 高健@博客园  luckyjackgao@gmail.com] 
回到上一级页面:PostgreSQL基础知识与基本操作索引页    回到顶级页面:PostgreSQL索引页磨砺技术珠矶,践行数据之道,追求卓越价值

对PostgreSQL数据库的hstore类型建立GisT索引的实验的更多相关文章

  1. Python numpy插入、读取至postgreSQL数据库中bytea类型字段

    安装psycopg2模块,此模块用于连接PostgreSQL数据库 ​pip install psycopg2 # -*- coding: utf-8 -*- import psycopg2 impo ...

  2. 建立安全SSL连接PostgreSQL数据库服务器

    建立安全SSL连接PostgreSQL数据库服务器当前物联网的挑战之一就是提供最高的安全级别.这就是为什么需要开启SSL连接到 PostgreSQL. 当你想要安全的存储数据到PostgreSQL数据 ...

  3. PostgreSQL数据库资料(转)

    PostgreSQL数据库资料 转自:http://blog.csdn.net/postgrechina/article/details/49132791 推荐书籍: 概念书籍: <Postgr ...

  4. postgreSQL数据库(索引、视图)

    索引的含义与特点 索引是一个单独的.存储在磁盘上的数据库结构,它们包含对数据所有记录的引用指针,postgresql列类型都可以被索引,对相关列索引是提高查询操作效率的最佳途径.例如,查询select ...

  5. 对Oracle 、SQL Server、MySQL、PostgreSQL数据库优缺点分析

    对Oracle .SQL Server.MySQL.PostgreSQL数据库优缺点分析 Oracle Database Oracle Database,又名Oracle RDBMS,或简称Oracl ...

  6. PostgreSQL数据库一些tricks

    PostgreSQL自带Pgadmin客户端,可用于访问本地和远程PG库,一些tricks如下: 1.联合查询 SELECT * FROM table1 INNER JOIN table2 ON ta ...

  7. Oracle数据库迁移至PostgreSQL数据库问题及解决

    Oracle数据库迁移PostgreSQL数据库问题及解决 目录 如何计划迁移数据库(现状及问题分析) 统计系统表及表功能 解耦公共表 建立数据库 迁移表结构 导入表数据 改SQL语法 保证数据时效性 ...

  8. MySQL&SQL server&Oracle&Access&PostgreSQL数据库sql注入详解

    判断数据库的类型 当我们通过一些测试,发现存在SQL注入之后,首先要做的就是判断数据库的类型. 常用的数据库有MySQL.Access.SQLServer.Oracle.PostgreSQL.虽然绝大 ...

  9. PostgreSQL介绍以及如何开发框架中使用PostgreSQL数据库

    最近准备下PostgreSQL数据库开发的相关知识,本文把总结的PPT内容通过博客记录分享,本随笔的主要内容是介绍PostgreSQL数据库的基础信息,以及如何在我们的开发框架中使用PostgreSQ ...

随机推荐

  1. Eclipse导入web项目发布项目时报Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web错误解决方案

    Eclipse导入web项目后,将web项目加载到server进行发布时,提示Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java ...

  2. spring boot项目中使用sfl4j+logbak配置

    1.pom.xml文件 <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api& ...

  3. redis安装及测试

    http://jingyan.baidu.com/article/9113f81b0333e12b3214c7a8.html 下载地址:http://git.oschina.net/bingoPure ...

  4. 【转】Spring+Mybatis+SpringMVC+Maven+MySql搭建实例

    林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:本文主要讲了如何使用Maven来搭建Spring+Mybatis+SpringMVC+M ...

  5. CS20Chapter3

    waiting  P54 shuffle data 03_Lecture note_Linear and Logistic Regression 学习点1: python的地址输入是要不能用正斜杠\的 ...

  6. jFinal 2.2入门学习之一:搭建框架输出helloword

    官方推荐用Eclipse IDE for Java EE Developers 做为开发环境 1.创建 Dynamic Web Project 2.修改 Default Output Folder,推 ...

  7. python动态调用函数

    callmap = {ts.get_stock_basics: 'D:/dxw/code/all.csv', ts.get_sz50s: 'D:/dxw/code/50.csv', ts.get_hs ...

  8. ios开发UI篇—UISlider

    概述 UISlider用于从连续范围的值中选择单个值的控件. 当您移动滑块的大拇指时,会将其更新后的值传递给附加的任何动作.滑块的外观是可配置的; 您可以对曲目和大拇指进行着色,并提供出现在滑块末端的 ...

  9. iOS原生分享功能

    iOS_系统原生分享 - CSDN博客 通过UIActivityViewController实现更多分享服务 - 简书 UIActivity - UIKit _ Apple Developer Doc ...

  10. angular setInterval计时操作

    在angular中setInterval方法是单向绑定,只绑定一次,无法实现计时效果, 可以使用$interval实现.附上代码: