2021-04-26

MySQL query takes 2 minutes

I have a problem. I am running a MySQL PhpMyAdmin server and I have 3 tables:

  • CandlestickData
  • CandlestickDataHist1
  • CandlestickDataHist2

Then I created a few with the following source query:

SELECT
    a.*
FROM
    (
    SELECT
        *,
        'CandlestickData' AS SOURCE
    FROM
        CandlestickData
    UNION
SELECT
    *,
    'CandlestickDataHist1' AS SOURCE
FROM
    CandlestickDataHist1
UNION
SELECT
    *,
    'CandlestickDataHist2' AS SOURCE
FROM
    CandlestickDataHist2
) AS a
ORDER BY
    a.MainKey
DESC

This gives me a view with 1.7 million records. When I do the following simple query on the view:

SELECT * FROM my_created_view;

It takes arround 2 minutes to execute the query. Is there a way to make it faster?



from Recent Questions - Stack Overflow https://ift.tt/3u4jHcE
https://ift.tt/eA8V8J

No comments:

Post a Comment