Further index changes.

This commit is contained in:
Patrick Fic
2024-09-20 15:56:42 -07:00
parent f674fff930
commit 464f7044f0
22 changed files with 162 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE OR REPLACE FUNCTION public.search_exportlog(search text)
-- RETURNS SETOF exportlog
-- LANGUAGE plpgsql
-- STABLE
-- AS $function$ BEGIN IF search = '' THEN RETURN query
-- SELECT
-- *
-- FROM
-- exportlog e;
-- ELSE RETURN query
-- SELECT
-- e.*
-- FROM
-- exportlog e
-- LEFT JOIN jobs j on j.id = e.jobid
-- LEFT JOIN payments p
-- ON p.id = e.paymentid
-- LEFT JOIN bills b
-- ON e.billid = b.id
-- WHERE
-- (
-- j.ro_number ILIKE '%' || search
-- OR b.invoice_number ILIKE '%' || search
-- OR p.paymentnum ILIKE '%' || search
-- OR e.useremail ILIKE '%' || search
-- )
-- AND (e.jobid = j.id
-- or e.paymentid = p.id
-- or e.billid = b.id)
-- ;
-- END IF;
-- END $function$;

View File

@@ -0,0 +1,32 @@
CREATE OR REPLACE FUNCTION public.search_exportlog(search text)
RETURNS SETOF exportlog
LANGUAGE plpgsql
STABLE
AS $function$ BEGIN IF search = '' THEN RETURN query
SELECT
*
FROM
exportlog e;
ELSE RETURN query
SELECT
e.*
FROM
exportlog e
LEFT JOIN jobs j on j.id = e.jobid
LEFT JOIN payments p
ON p.id = e.paymentid
LEFT JOIN bills b
ON e.billid = b.id
WHERE
(
j.ro_number ILIKE '%' || search
OR b.invoice_number ILIKE '%' || search
OR p.paymentnum ILIKE '%' || search
OR e.useremail ILIKE '%' || search
)
AND (e.jobid = j.id
or e.paymentid = p.id
or e.billid = b.id)
;
END IF;
END $function$;

View File

@@ -0,0 +1,34 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE OR REPLACE FUNCTION public.search_exportlog(search text)
-- RETURNS SETOF exportlog
-- LANGUAGE plpgsql
-- STABLE
-- AS $function$ BEGIN IF search = '' THEN RETURN query
-- SELECT
-- *
-- FROM
-- exportlog e;
-- ELSE RETURN query
-- SELECT
-- e.*
-- FROM
-- exportlog e
-- LEFT JOIN jobs j on j.id = e.jobid
-- LEFT JOIN payments p
-- ON p.id = e.paymentid
-- LEFT JOIN bills b
-- ON e.billid = b.id
-- WHERE
-- (
-- j.ro_number ILIKE '%' || search
-- OR b.invoice_number ILIKE '%' || search
-- OR p.paymentnum ILIKE '%' || search
-- OR e.useremail ILIKE '%' || search
-- )
-- AND (e.jobid = j.id
-- or e.paymentid = p.id
-- or e.billid = b.id)
-- ;
-- END IF;
-- END $function$;

View File

@@ -0,0 +1,32 @@
CREATE OR REPLACE FUNCTION public.search_exportlog(search text)
RETURNS SETOF exportlog
LANGUAGE plpgsql
STABLE
AS $function$ BEGIN IF search = '' THEN RETURN query
SELECT
*
FROM
exportlog e;
ELSE RETURN query
SELECT
e.*
FROM
exportlog e
LEFT JOIN jobs j on j.id = e.jobid
LEFT JOIN payments p
ON p.id = e.paymentid
LEFT JOIN bills b
ON e.billid = b.id
WHERE
(
j.ro_number ILIKE '%' || search
OR b.invoice_number ILIKE '%' || search
OR p.paymentnum ILIKE '%' || search
OR e.useremail ILIKE '%' || search
)
AND (e.jobid = j.id
or e.paymentid = p.id
or e.billid = b.id)
;
END IF;
END $function$;

View File

@@ -0,0 +1 @@
DROP INDEX IF EXISTS "public"."idx_bill_invoice_number";

View File

@@ -0,0 +1,2 @@
CREATE INDEX "idx_bill_invoice_number" on
"public"."bills" using btree ("invoice_number");

View File

@@ -0,0 +1 @@
DROP INDEX IF EXISTS "public"."idx_payments_paymentnum";

View File

@@ -0,0 +1,2 @@
CREATE INDEX "idx_payments_paymentnum" on
"public"."payments" using btree ("paymentnum");

View File

@@ -0,0 +1 @@
DROP INDEX IF EXISTS "public"."exportlog_useremail";

View File

@@ -0,0 +1,2 @@
CREATE INDEX "exportlog_useremail" on
"public"."exportlog" using btree ("useremail");

View File

@@ -0,0 +1 @@
DROP INDEX IF EXISTS "public"."available_jobs_jobid";

View File

@@ -0,0 +1,2 @@
CREATE INDEX "available_jobs_jobid" on
"public"."available_jobs" using btree ("jobid");

View File

@@ -0,0 +1,3 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE INDEX idx_jobslines_ordering ON joblines (jobid, removed, line_no asc) where removed=false;

View File

@@ -0,0 +1 @@
CREATE INDEX idx_jobslines_ordering ON joblines (jobid, removed, line_no asc) where removed=false;

View File

@@ -0,0 +1,3 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE INDEX idx_joblines_types ON joblines (jobid, mod_lbr_ty, removed) where removed=false;

View File

@@ -0,0 +1 @@
CREATE INDEX idx_joblines_types ON joblines (jobid, mod_lbr_ty, removed) where removed=false;

View File

@@ -0,0 +1,3 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE INDEX idx_exportlog_created_at_desc ON exportlog (created_at desc);

View File

@@ -0,0 +1 @@
CREATE INDEX idx_exportlog_created_at_desc ON exportlog (created_at desc);

View File

@@ -0,0 +1,2 @@
CREATE INDEX "joblines_idx_removed" on
"public"."joblines" using btree ("removed");

View File

@@ -0,0 +1 @@
DROP INDEX IF EXISTS "public"."joblines_idx_removed";

View File

@@ -0,0 +1,2 @@
CREATE INDEX "joblines_idx_line_no" on
"public"."joblines" using btree ("jobid", "line_no");

View File

@@ -0,0 +1 @@
DROP INDEX IF EXISTS "public"."joblines_idx_line_no";