Commit e3896404 authored by Kalinka's avatar Kalinka

Controller/BlockController.php:

  - use in memory account data
Controller/TransactionController.php:
  - JOINS only with indexed attributes
parent a3480c78
......@@ -25,8 +25,8 @@ class BlockController extends AbstractController
ap.name AS pool_name
FROM block b
LEFT JOIN block_info bi ON (b.height = bi.height)
LEFT JOIN account af ON (bi.generator_id = af.id AND af.latest = 1)
LEFT JOIN account ap ON (bi.recipient_id = ap.id AND ap.latest = 1)
LEFT JOIN ec_account af ON (bi.generator_id = af.id)
LEFT JOIN ec_account ap ON (bi.recipient_id = ap.id)
WHERE b.db_id IN (?)
ORDER BY b.db_id DESC -- BlockController/BlockListByIds';
......@@ -54,8 +54,8 @@ class BlockController extends AbstractController
FORMAT(b.timestamp / b.height, 0) AS average_block_time
FROM block b
LEFT JOIN block_info bi ON (b.height = bi.height)
LEFT JOIN account af ON (bi.generator_id = af.id AND af.latest = 1)
LEFT JOIN account ap ON (bi.recipient_id = ap.id AND ap.latest = 1)
LEFT JOIN ec_account af ON (bi.generator_id = af.id)
LEFT JOIN ec_account ap ON (bi.recipient_id = ap.id)
LEFT JOIN block nb ON (b.id = nb.previous_block_id)
LEFT JOIN block pb ON (b.previous_block_id = pb.id)
WHERE CAST(b.id AS UNSIGNED) = ? -- BlockController/BlockDetails';
......@@ -82,8 +82,8 @@ class BlockController extends AbstractController
FORMAT(b.timestamp / b.height, 0) AS average_block_time
FROM block b
LEFT JOIN block_info bi ON (b.height = bi.height)
LEFT JOIN account af ON (bi.generator_id = af.id AND af.latest = 1)
LEFT JOIN account ap ON (bi.recipient_id = ap.id AND ap.latest = 1)
LEFT JOIN ec_account af ON (bi.generator_id = af.id)
LEFT JOIN ec_account ap ON (bi.recipient_id = ap.id)
LEFT JOIN block nb ON (b.id = nb.previous_block_id)
LEFT JOIN block pb ON (b.previous_block_id = pb.id)
WHERE b.height = ? -- BlockController/BlockDetailsHeight';
......
......@@ -8,6 +8,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use PDO;
class TransactionController extends AbstractController
{
......@@ -47,8 +48,8 @@ class TransactionController extends AbstractController
JOIN mos ON (mos.db_id = mosr.db_id)
JOIN transaction t ON (mosr.db_id = t.db_id AND t.height = ?)
) as x
LEFT JOIN account s ON (x.sender_id = s.id AND s.latest = 1)
LEFT JOIN account r ON (x.recipient_id = r.id AND r.latest = 1)
LEFT JOIN ec_account s ON (x.sender_id = s.id)
LEFT JOIN ec_account r ON (x.recipient_id = r.id)
WHERE x.recipient_id IS NOT NULL -- TransactionController/TransactionsByHeight";
......@@ -86,8 +87,8 @@ class TransactionController extends AbstractController
JOIN mos ON (mos.db_id = mosr.db_id)
JOIN transaction t ON (mosr.db_id = t.db_id AND CAST(t.block_id AS UNSIGNED) = ?)
) as x
LEFT JOIN account s ON (x.sender_id = s.id AND s.latest = 1)
LEFT JOIN account r ON (x.recipient_id = r.id AND r.latest = 1)
LEFT JOIN ec_account s ON (x.sender_id = s.id)
LEFT JOIN ec_account r ON (x.recipient_id = r.id)
WHERE x.recipient_id IS NOT NULL -- TransactionController/TransactionsByBlockId";
const TransactionCountByAccountId = "
......@@ -130,8 +131,8 @@ class TransactionController extends AbstractController
CAST(t.block_id AS UNSIGNED) as block_id,
t.height
FROM mo
LEFT JOIN transaction t ON (mo.db_id = t.db_id AND t.type = 0 AND t.subtype = 1)
WHERE CAST(mo.recipient_id AS UNSIGNED) = ?
LEFT JOIN transaction t ON (mo.db_id = t.db_id)
WHERE CAST(mo.recipient_id AS UNSIGNED) = ? AND t.type = 0 AND t.subtype = 1
UNION -- Outgoing MultiOut Transactions, Pool 0,0s
SELECT CAST(t.id AS UNSIGNED) AS id,
CAST(t.sender_id AS UNSIGNED) AS sender_id,
......@@ -157,8 +158,8 @@ class TransactionController extends AbstractController
t.height
FROM mosr
LEFT JOIN mos ON (mosr.db_id = mos.db_id)
LEFT JOIN transaction t ON (mosr.db_id = t.db_id AND t.type = 0 AND t.subtype = 2)
WHERE CAST(mosr.recipient_id AS UNSIGNED) = ?
LEFT JOIN transaction t ON (mosr.db_id = t.db_id)
WHERE CAST(mosr.recipient_id AS UNSIGNED) = ? AND t.type = 0 AND t.subtype = 2
UNION -- Outgoing MultiOutSame Transactions, Pool 3,1s
SELECT CAST(t.id AS UNSIGNED) AS id,
CAST(t.sender_id AS UNSIGNED) AS sender_id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment