explain.depesz.com

PostgreSQL's explain analyze made readable

Result: RX4w

Settings
# exclusive inclusive rows x rows loops node
1. 0.203 203.452 ↑ 1.0 1 1

Aggregate (cost=182,450.87..182,450.88 rows=1 width=8) (actual time=203.452..203.452 rows=1 loops=1)

2. 0.477 203.249 ↓ 3,592.0 3,592 1

Unique (cost=182,450.85..182,450.86 rows=1 width=12) (actual time=202.523..203.249 rows=3,592 loops=1)

3. 1.219 202.772 ↓ 3,594.0 3,594 1

Sort (cost=182,450.85..182,450.85 rows=1 width=12) (actual time=202.522..202.772 rows=3,594 loops=1)

  • Sort Key: ((SubPlan 1)) DESC NULLS LAST, clients_client.id DESC
  • Sort Method: quicksort Memory: 265kB
4. 2.459 201.553 ↓ 3,594.0 3,594 1

Nested Loop (cost=177,939.55..182,450.84 rows=1 width=12) (actual time=167.100..201.553 rows=3,594 loops=1)

5. 1.724 177.204 ↓ 1.3 3,757 1

Nested Loop (cost=177,939.13..180,961.13 rows=2,940 width=4) (actual time=167.075..177.204 rows=3,757 loops=1)

6. 2.080 167.966 ↓ 1.3 3,757 1

HashAggregate (cost=177,938.71..177,968.11 rows=2,940 width=4) (actual time=167.067..167.966 rows=3,757 loops=1)

  • Group Key: v0.id
7. 1.571 165.886 ↓ 1.3 3,757 1

Nested Loop (cost=0.70..177,931.36 rows=2,940 width=4) (actual time=0.041..165.886 rows=3,757 loops=1)

8. 0.224 0.224 ↑ 1.0 249 1

Index Scan using accounts_employeegroup_447d3092 on accounts_employeegroup v1 (cost=0.28..140.20 rows=249 width=4) (actual time=0.010..0.224 rows=249 loops=1)

  • Index Cond: (company_id = 18855)
9. 75.043 164.091 ↑ 1.5 15 249

Index Scan using clients_groupassignment_group_id_692cd6dd on clients_groupassignment v0 (cost=0.42..713.80 rows=22 width=8) (actual time=0.144..0.659 rows=15 loops=249)

  • Index Cond: ((group_id = v1.id) AND (group_id = ANY ('{1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1150,1151,1152,1153,1154,1155,1156,1157,1158,1159,1160,1161,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1326,1446,1468}'::integer[])))
  • Filter: ((status = ANY ('{10,15}'::integer[])) AND (NOT (alternatives: SubPlan 2 or hashed SubPlan 3)))
  • Rows Removed by Filter: 384
10.          

SubPlan (for Index Scan)

11. 3.103 89.048 ↑ 1.0 1 22,262

Nested Loop (cost=1.00..5.46 rows=1 width=0) (actual time=0.004..0.004 rows=1 loops=22,262)

12. 3.103 66.786 ↑ 1.0 1 22,262

Nested Loop (cost=0.71..5.15 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=22,262)

13. 44.524 44.524 ↑ 1.0 1 22,262

Index Only Scan using clients_client_agents_client_id_37afacd828f1e2f6_uniq on clients_client_agents u3 (cost=0.42..2.64 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=22,262)

  • Index Cond: (client_id = v0.client_id)
  • Heap Fetches: 16715
14. 19.159 19.159 ↑ 1.0 1 19,159

Index Only Scan using auth_user_pkey on auth_user u0_1 (cost=0.29..2.51 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=19,159)

  • Index Cond: (id = u3.user_id)Heap Fetches: 18488
15. 19.159 19.159 ↑ 1.0 1 19,159

Index Only Scan using accounts_employeegroup_employees_employeegroup_id_user_id_key on accounts_employeegroup_employees u1 (cost=0.29..0.31 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=19,159)

  • Index Cond: ((employeegroup_id = v0.group_id) AND (user_id = u0_1.id))
  • Heap Fetches: 7820
16. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=2,003.74..19,914.22 rows=571,474 width=8) (never executed)

  • Hash Cond: (u3_1.user_id = u0_2.id)
17. 0.000 0.000 ↓ 0.0 0

Seq Scan on clients_client_agents u3_1 (cost=0.00..9,820.90 rows=633,290 width=8) (never executed)

18. 0.000 0.000 ↓ 0.0 0

Hash (cost=1,684.57..1,684.57 rows=25,534 width=12) (never executed)

19. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=1,209.19..1,684.57 rows=25,534 width=12) (never executed)

  • Hash Cond: (u1_1.user_id = u0_2.id)
20. 0.000 0.000 ↓ 0.0 0

Seq Scan on accounts_employeegroup_employees u1_1 (cost=0.00..408.34 rows=25,534 width=8) (never executed)

21. 0.000 0.000 ↓ 0.0 0

Hash (cost=855.49..855.49 rows=28,296 width=4) (never executed)

22. 0.000 0.000 ↓ 0.0 0

Index Only Scan using auth_user_pkey on auth_user u0_2 (cost=0.29..855.49 rows=28,296 width=4) (never executed)

  • Heap Fetches: 0
23. 7.514 7.514 ↑ 1.0 1 3,757

Index Scan using clients_groupassignment_pkey on clients_groupassignment (cost=0.42..1.02 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=3,757)

  • Index Cond: (id = v0.id)
24. 7.514 7.514 ↑ 1.0 1 3,757

Index Scan using clients_client_pkey on clients_client (cost=0.42..0.51 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=3,757)

  • Index Cond: (id = clients_groupassignment.client_id)
  • Filter: ((status <> ALL ('{50,70}'::integer[])) AND (brokerage_id = 18855))
  • Rows Removed by Filter: 0
25.          

SubPlan (for Nested Loop)

26. 3.594 14.376 ↑ 1.0 1 3,594

Limit (cost=2.96..2.97 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=3,594)

27. 0.000 10.782 ↑ 1.0 1 3,594

Sort (cost=2.96..2.97 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=3,594)

  • Sort Key: u0.updated_at DESC NULLS LAST
  • Sort Method: quicksort Memory: 25kB
28. 10.782 10.782 ↑ 1.0 1 3,594

Index Scan using clients_groupassignment_client_id_4c897251 on clients_groupassignment u0 (cost=0.42..2.95 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=3,594)

  • Index Cond: (client_id = clients_client.id)
  • Filter: (group_id = ANY ('{1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1150,1151,1152,1153,1154,1155,1156,1157,1158,1159,1160,1161,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1326,1446,1468}'::integer[]))
Planning time : 2.436 ms
Execution time : 203.557 ms