Datenbankkonfiguration:
Code:
shared_buffers = 4GB
work_mem = 64MB
effective_cache_size = 12GB
random_page_cost = 1.0
Query Plan:
Code:
Limit (cost=216637.55..216637.60 rows=20 width=8) (actual time=4287.988..4287.994 rows=20 loops=1)
CTE bauteil_ids
-> Bitmap Heap Scan on bauteile (cost=9.59..17.81 rows=10 width=4) (actual time=0.049..0.060 rows=10 loops=1)
Recheck Cond: (id = ANY ('{3145,4466,4323,4452,3095,3195,4131,3140,3189,4512}'::integer[]))
-> Bitmap Index Scan on bauteile_id (cost=0.00..9.59 rows=10 width=0) (actual time=0.039..0.039 rows=10 loops=1)
Index Cond: (id = ANY ('{3145,4466,4323,4452,3095,3195,4131,3140,3189,4512}'::integer[]))
-> Sort (cost=216619.74..217335.28 rows=286215 width=8) (actual time=4287.987..4287.989 rows=20 loops=1)
Sort Key: (sum(CASE WHEN (NOT (alternatives: SubPlan 2 or hashed SubPlan 3)) THEN 1 ELSE 0 END)), (count(*))
Sort Method: top-N heapsort Memory: 26kB
-> HashAggregate (cost=140312.06..209003.66 rows=286215 width=8) (actual time=3918.583..4157.986 rows=501302 loops=1)
-> Seq Scan on zuordnung (cost=0.00..103155.32 rows=4954232 width=8) (actual time=0.012..807.174 rows=4954232 loops=1)
SubPlan 2
-> CTE Scan on bauteil_ids (cost=0.00..0.22 rows=1 width=0) (never executed)
Filter: (id = $1)
SubPlan 3
-> CTE Scan on bauteil_ids (cost=0.00..0.20 rows=10 width=4) (actual time=0.052..0.068 rows=10 loops=1)
Total runtime: 4289.296 ms
Tabellendefinitionen:
Bauteile:
Code:
CREATE TABLE bauteile
(
id serial NOT NULL,
"name" character varying(255) NOT NULL,
CONSTRAINT bauteile_pkey PRIMARY KEY (id),
CONSTRAINT bauteile_name_uniq UNIQUE (name)
)
WITH (
OIDS=FALSE
);
CREATE UNIQUE INDEX bauteile_id
ON bauteile
USING btree
(id);
Produkte:
Code:
CREATE TABLE produkte
(
id serial NOT NULL,
"name" character varying(255),
CONSTRAINT produkte_pkey PRIMARY KEY (id),
)
WITH (
OIDS=FALSE
);
ALTER TABLE produkte OWNER TO defaultuser;
Zuordnung:
Code:
CREATE TABLE zuordnung
(
id serial NOT NULL,
produkt_id integer NOT NULL,
bauteil_id integer,
CONSTRAINT zuordnung_pkey PRIMARY KEY (id),
CONSTRAINT bauteil_id_refs_id_1ada94fb3ba2efc3 FOREIGN KEY (bauteil_id)
REFERENCES bauteile (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT produkt_id_refs_id_45191a629e4145fe FOREIGN KEY (produkt_id)
REFERENCES produkte (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
)
WITH (
OIDS=FALSE
);
CREATE UNIQUE INDEX zuordnung_id_idx
ON zuordnung
USING btree
(id)
WITH (FILLFACTOR=10);
CREATE INDEX zuordnung_bauteil_id
ON zuordnung
USING btree
(bauteil_id)
WITH (FILLFACTOR=10);
CREATE INDEX zuordnung_produkt_id
ON zuordnung
USING btree
(produkt_id)
WITH (FILLFACTOR=10);
So, und nun noch zu der Sache mit den Umlauten:
Ich habe den Text schön im Browser (Chrome) geschrieben und nicht rumkopiert. Als ich den Beitrag abgeschickt habe, war ich bereits ausgeloggt, musste mich also neu einloggen. Danach wurde mein Beitrag automatisch gepostet (so wie es sein soll), aber die Umlaute waren zerhackt.
Und ja, ich würde das jemand der es mir in meinem Forum erzählt auch nicht glauben und mir denken, "der hat bestimmt irgendwas falsch gemacht", aber es war genau so
Lesezeichen