MySQL Forums
Forum List  »  German

MYSQL:: Geht das auch schneller: über zwei IDS (Tabelle1) eine Spalte aus Tabelle2
Posted by: Thomas Cater
Date: January 31, 2019 12:07PM

SELECT b.*
FROM
(
SELECT chat_id, user_id, conversation as 'conversation'
FROM `chat`
UNION SELECT chat_id, partner_id as user_id, conversation AS `conversation`
FROM `chat`
) as b,
(
SELECT id
FROM user_visitor
WHERE
(
`firstname` LIKE "Patrick"
AND `lastname` LIKE "Black"
) OR (
`firstname` LIKE "Michael"
AND `lastname` LIKE "Waldbauer"
)
) as a
where b.user_id = a.id
GROUP BY `chat_id`
having count(*) = 2


Dieses Statement funktioniert und liefert auch die "Conversation" zurück.

Die Master Frage:
Geht das auch noch schneller? 0.0095 Sekunden ist langsamer.

DAUER: 0.0016 Sekunden
SELECT id
FROM user_visitor
WHERE
    (
        `firstname` LIKE "James"
        AND`lastname` LIKE "Keith"
    ) OR (
        `firstname` LIKE "Patrick"
        AND`lastname` LIKE "Black"
    )
Limit 0,2

DAUER: UNBEKANNT
$row          = mysql::executeResult($statment);
$id_one       = $row[0]['id'];
$id_second    = $row[1]['id'];

DAUER: 0.0014 Sekunden
SELECT `conversation`
FROM `chat`
WHERE
(`partner_id` = 18 AND `user_id` = 16 )
OR (`user_id` = 18 AND `partner_id` = 16)
LIMIT 0,1

INSGESAMT-DAUER CA: 0.0046 Sekunden

In zwei Statements ohne MYSQL ist es eindeutig schneller,...

Geht es noch schneller?

Options: ReplyQuote


Subject
Views
Written By
Posted
MYSQL:: Geht das auch schneller: über zwei IDS (Tabelle1) eine Spalte aus Tabelle2
329
January 31, 2019 12:07PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.