A view V$SQL mostra as instruções SQL que estão no pool compartilhado juntamente com estatísticas sobre sua operação. Isso a torna essencial para examinar as instruções SQL. Este post será bem curto e objetivo, mostrando 3 exemplos de consultas utilizando essa view de forma bem prática e útil.

Top 10 – SQL mais executados:

[et_pb_dmb_code_snippet _builder_version=”4.0.6″ code=”U0VMRUNUIHNxbF90ZXh0LCBleGVjdXRpb25zCiAgRlJPTSAoU0VMRUNUIHNxbF90ZXh0LCBleGVjdXRpb25zLAogICAgICAgIFJBTksoKSBPVkVSIChPUkRFUiBCWSBleGVjdXRpb25zIERFU0MpIGV4ZWNfcmFuawogICAgICAgIEZST00gdiRzcWwpCiBXSEVSRSBleGVjX3JhbmsgPD0gMTA7″ hover_enabled=”0″]U0VMRUNUIHNxbF90ZXh0LCBleGVjdXRpb25zCiAgRlJPTSAoU0VMRUNUIHNxbF90ZXh0LCBleGVjdXRpb25zLAogICAgICAgIFJBTksoKSBPVkVSIChPUkRFUiBCWSBleGVjdXRpb25zIERFU0MpIGV4ZWNfcmFuawogICAgICAgIEZST00gdiRzcWwpCiBXSEVSRSBleGVjX3JhbmsgPD0gMTA7[/et_pb_dmb_code_snippet]

Top 10 – SQL que mais exigiram leituras físicas:

[et_pb_dmb_code_snippet _builder_version=”4.0.6″ code=”U0VMRUNUIHNxbF90ZXh0LCBkaXNrX3JlYWRzCiAgRlJPTSAoU0VMRUNUIHNxbF90ZXh0LCBkaXNrX3JlYWRzLAogICAgICAgIERFTlNFX1JBTksoKSBPVkVSCiAgICAgICAgICAoT1JERVIgQlkgZGlza19yZWFkcyBERVNDKSBEaVNrX1JFQURTX1JBTksKICAgICAgIEZST00gdiRzcWwpCiBXSEVSRSBkaXNrX3JlYWRzX3JhbmsgPD0gMTA7″ hover_enabled=”0″]U0VMRUNUIHNxbF90ZXh0LCBkaXNrX3JlYWRzCiAgRlJPTSAoU0VMRUNUIHNxbF90ZXh0LCBkaXNrX3JlYWRzLAogICAgICAgIERFTlNFX1JBTksoKSBPVkVSCiAgICAgICAgICAoT1JERVIgQlkgZGlza19yZWFkcyBERVNDKSBEaVNrX1JFQURTX1JBTksKICAgICAgIEZST00gdiRzcWwpCiBXSEVSRSBkaXNrX3JlYWRzX3JhbmsgPD0gMTA7[/et_pb_dmb_code_snippet]

Top 10 – SQL que mais exigiram leituras lógicas:

[et_pb_dmb_code_snippet _builder_version=”4.0.6″ code=”U0VMRUNUIHNxbF90ZXh0LCBidWZmZXJfZ2V0cwogIEZST00gKFNFTEVDVCBzcWxfdGV4dCwgYnVmZmVyX2dldHMsCiAgICAgICAgICAgICAgREVOU0VfUkFOSygpIE9WRVIKICAgICAgICAgICAgICAoT1JERVIgQlkgYnVmZmVyX2dldHMgREVTQykgYnVmZmVyX2dldHNfcmFuawogICAgICAgIEZST00gdiRzcWwpCiBXSEVSRSBidWZmZXJfZ2V0c19yYW5rIDw9IDEwOw==” hover_enabled=”0″]U0VMRUNUIHNxbF90ZXh0LCBidWZmZXJfZ2V0cwogIEZST00gKFNFTEVDVCBzcWxfdGV4dCwgYnVmZmVyX2dldHMsCiAgICAgICAgICAgICAgREVOU0VfUkFOSygpIE9WRVIKICAgICAgICAgICAgICAoT1JERVIgQlkgYnVmZmVyX2dldHMgREVTQykgYnVmZmVyX2dldHNfcmFuawogICAgICAgIEZST00gdiRzcWwpCiBXSEVSRSBidWZmZXJfZ2V0c19yYW5rIDw9IDEwOw==[/et_pb_dmb_code_snippet]

Fique a vontade para alterar as consultas acima – você pode alterar o “top 10” para top 5, top 20, ou o número que quiser – basta alterar o valor da cláusula WHERE de cada consulta.