Optimering af databasekald.
PostgreSQL optimering!..jeg har g.user_id at gå ud fra, og jeg ønsker at hente u.id og u.username ud samt g.approved
tabel g
-----------------
group_id, user_id, approved
tabel n
-----------------
user_id, buddylist_groupid
tabel u
-----------------
id, username
FACTS:
-------
g.group_id=n.buddylist_groupid
n.user_id=u.userid
g.approved=0
min løsning
----------
g.user_id -> g.group_id -> n.buddylist_groupid -> n.user_id -> u.*
SELECT u.*, g.approved FROM group_namespace_buddylist g, users u, user_namespace_spil n WHERE n.user_id = u.id AND g.user_id = ? AND g.group_id = n.buddylist_groupid AND g.approved = 0;
KAN DEN OPTIMERES? :)
komplet beskrivelse af tabellerne.
--------
buddylist g
----------------------------------------
Column | Type | Modifiers
--------------+---------+---------------
group_id | integer | not null
user_id | integer | not null
approved | boolean | default false
name_spil n
-----------------------------------------------------
Column | Type | Modifiers
-------------------------+---------------+-----------
user_id | integer | not null
buddylist_groupid | integer |
users
-----------------------------------------------------------------------------------
Column | Type | Modifiers
----------+-----------------------+------------------------------------------------
id | integer | not null default nextval('users_id_seq'::text)
username | character varying(64) | not null
status | integer | not null