Skip to content
Snippets Groups Projects

GIN index uses to find posts by tag

Merged Marcin requested to merge mi_gin_posts_tags into develop
Compare and
9 files
+ 107
154
Compare changes
  • Side-by-side
  • Inline
Files
9
 
do $$
 
BEGIN
 
ASSERT EXISTS (SELECT * FROM pg_extension WHERE extname='intarray'), 'The database requires createed "intarray" extension';
 
END$$;
 
CREATE TABLE IF NOT EXISTS hive_db_patch_level
CREATE TABLE IF NOT EXISTS hive_db_patch_level
(
(
level SERIAL NOT NULL PRIMARY KEY,
level SERIAL NOT NULL PRIMARY KEY,
@@ -213,6 +218,15 @@ IF NOT EXISTS (SELECT data_type FROM information_schema.columns
@@ -213,6 +218,15 @@ IF NOT EXISTS (SELECT data_type FROM information_schema.columns
ELSE
ELSE
RAISE NOTICE 'SKIPPING hive_posts upgrade - adding total_votes and net_votes columns';
RAISE NOTICE 'SKIPPING hive_posts upgrade - adding total_votes and net_votes columns';
END IF;
END IF;
 
 
IF NOT EXISTS(SELECT data_type FROM information_schema.columns
 
WHERE table_name = 'hive_posts' AND column_name = 'tags_ids') THEN
 
ALTER TABLE ONLY hive_posts
 
ADD COLUMN tags_ids INTEGER[];
 
ELSE
 
RAISE NOTICE 'SKIPPING hive_posts upgrade - adding a tags_ids column';
 
END IF;
 
END
END
$BODY$
$BODY$
@@ -383,3 +397,6 @@ DROP INDEX IF EXISTS hive_posts_promoted_idx;
@@ -383,3 +397,6 @@ DROP INDEX IF EXISTS hive_posts_promoted_idx;
CREATE INDEX IF NOT EXISTS hive_posts_promoted_id_idx ON hive_posts (promoted, id)
CREATE INDEX IF NOT EXISTS hive_posts_promoted_id_idx ON hive_posts (promoted, id)
WHERE NOT is_paidout AND counter_deleted = 0
WHERE NOT is_paidout AND counter_deleted = 0
;
;
 
 
 
CREATE INDEX IF NOT EXISTS hive_posts_tags_ids_idx ON hive_posts USING gin(tags_ids gin__int_ops);
Loading