finished this round of schema improvements
This commit is contained in:
@@ -8,6 +8,10 @@ http://okigiveup.net/what-postgresql-tells-you-about-its-performance/
|
||||
Useful queries to indicate how indexes are being used in postgresql
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
2020-05-21 THIS SUPERSEDES BELOW
|
||||
HOW TO FIND SHITTY INDEXES: https://gist.github.com/jberkus/6b1bcaf7724dfc2a54f3
|
||||
|
||||
==-=-=-
|
||||
OK: this is the best query to use to find non used indexes
|
||||
Run it and look for any indexes that are *not* primary keys (name ends in pkey, want ones that end in idx which are mine)
|
||||
that have zero in idx_scan, that means they are completely unused (if a lot of full test runs that excercise all routes and features have happened prior to checking)
|
||||
|
||||
@@ -1,65 +1,6 @@
|
||||
{"login": "manager","password": "l3tm3in"}
|
||||
|
||||
|
||||
todo: Search indexing performance improvement and exception avoidance (Search.cs 828)
|
||||
ON CONFLICT IDEA
|
||||
https://www.postgresql.org/docs/current/sql-insert.html#SQL-ON-CONFLICT
|
||||
Idea: do the insert manually with the clause "on conflict do nothing"
|
||||
if detect it hasn't inserted (conflict) trigger a fetch instead
|
||||
like what is being done now but won't have the exception to deal with!!
|
||||
var CtAdd.SearchDictionary.FromSqlRaw("insert into asearchdictionary (word) values('{0}') on conflict (word) do update set word=excluded.word returning id",KeyWord ).FirstOrDefaultAsync();
|
||||
|
||||
stored procedure?
|
||||
https://www.postgresqltutorial.com/plpgsql-loop-statements/
|
||||
-------
|
||||
CREATE OR REPLACE PROCEDURE public.aydosearchindex(wordlist text[], ayobjectid bigint, ayobjecttype integer, cleanfirst boolean)
|
||||
LANGUAGE 'plpgsql'
|
||||
|
||||
AS $BODY$DECLARE
|
||||
s text;
|
||||
wordid bigint;
|
||||
BEGIN
|
||||
IF ayobjectid=0 THEN
|
||||
RAISE EXCEPTION 'Bad object id --> %', ayobjectid;
|
||||
END IF;
|
||||
|
||||
IF ayobjecttype=0 THEN
|
||||
RAISE EXCEPTION 'Bad object type --> %', ayobjecttype;
|
||||
END IF;
|
||||
|
||||
|
||||
IF cleanfirst=true THEN
|
||||
delete from asearchkey where objectid=ayobjectid and objecttype=ayobjecttype;
|
||||
END IF;
|
||||
|
||||
FOREACH s IN ARRAY wordlist
|
||||
LOOP
|
||||
raise info 'processing word %',s;
|
||||
SELECT id INTO wordid FROM asearchdictionary WHERE word = s;
|
||||
raise info 'initial select found that word id is %', wordid;
|
||||
IF wordid = NULL THEN
|
||||
raise info 'since wordid was null inserting %...', wordid;
|
||||
insert into asearchdictionary (word) values(s) on conflict (word) do update set word=excluded.word returning id into wordid;
|
||||
raise info 'After insert new word returned word id %, inserting into searchkey', wordid;
|
||||
insert into asearchkey (wordid,objectid,objecttype) values(wordid,ayobjectid,ayobjecttype);
|
||||
ELSE
|
||||
raise info 'since we have initial word id from select inserting into search key the Word id %', wordid;
|
||||
insert into asearchkey (wordid,objectid,objecttype) values(wordid,ayobjectid,ayobjecttype);
|
||||
END IF;
|
||||
END LOOP;
|
||||
END;
|
||||
$BODY$;
|
||||
|
||||
------
|
||||
call aydosearchindex(ARRAY['sun','mon','tue','wed','thu','fri','sat'],3,3)
|
||||
-------
|
||||
|
||||
|
||||
|
||||
todo: Search confirm indexes are actually being used
|
||||
|
||||
|
||||
|
||||
todo: OPS notification created for failed jobs
|
||||
also maybe direct immediate email bypassing generator?
|
||||
Add backup fail to this will stub out for now
|
||||
|
||||
Reference in New Issue
Block a user