question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SQL parsing for span.name with db spans becomes Slow when calculating large SELECT columns FROM table WHERE column IN ('1', '2', ..., 'N') sql query

See original GitHub issue

APM Agent version

v1.15.0

Environment

Operating system and version:

Windows 10 Professional 21H2 19044.1826

Application Target Framework(s) (e.g. net461, netcoreapp3.1):

netcoreapp3.1

Describe the problem

SQL parsing for span.name with db spans becomes Slow when calculating large SELECT columns FROM table WHERE column IN ('1', '2', ..., 'N') sql query

image

Steps to reproduce

  1. Clone elastic/apm-agent-dotnet
  2. Checkout tag v1.15.0
  3. Modify test cases in test/Elastic.Apm.Tests/TestResources/db/sql_signature_examples.json as below
    [
      {
        "input": "SELECT [s].[Id], [s].[CreateTime], [s].[Duration], [s].[FullTextHash], [s].[OnShelf], [s].[SourceId], [s].[Title], [s].[Url], [s].[Version] FROM [Speech] AS [s] WHERE [s].[Id] IN ('FCD84661-F36C-4DB1-8B92-BE0668027163', '14274997-dcc7-4a7a-b866-41a007b36b9b', 'F163CB1D-6F21-4EFE-8DE7-EF27EC86E616', '0B72BD1E-D400-48BD-A2A2-3566434C4612', 'C6302F71-B70E-449A-B780-01BDCC154827', 'A68175D4-EE5D-44D2-A60B-BB266AD805D6', '83a36518-3956-44a3-aeb0-398eec87b583', '8DBEB3F6-9DA4-4B63-ADD8-21533DA75E62', '0bd15ff5-4eac-48fe-a18e-17d74a3809fa', '6EB539B6-804F-4ED9-ABBE-847E727B431A', '8A9C422D-492D-4EF6-9918-6E1EF6A28CFF', '546b40da-75cb-4d37-9e6e-954048561c5f', 'f7de8e24-0667-4fbc-9c72-be6c2dba1df8', '9C5B7DFE-25F5-4E9C-A817-5D2540F3082E', 'C32D88D6-467B-464B-97AC-8CA4FFB57665', '0CB61EE6-F46A-4D95-9109-CB3B76437D7B', 'C0E1DEA4-1C45-40BC-94CF-104BC2A3D027', '6E062867-81D5-4E71-AFF7-ADCE05ADF5DC', 'fbf61692-ee7b-4250-86d5-3dfa82dd575c', '933F13E9-328E-4F53-9424-50B3D7FE20BC', '809269AE-A9FA-4B15-BDB1-A23990F37094', '999605cd-03cd-4f1d-a4bb-17732e3d57fb', '6D426C5D-6606-4FAC-9852-8A37BE1E4855', '994CFA77-EBFD-4F47-8027-6AE27191DFE1', 'aaca9a7d-9e60-454c-899e-d882ebe645e7', '82D58CFC-AA6B-4096-AD7B-7DF9A17B0851', '8300FB66-1140-4B55-A835-6D23E71A2B60', '11E369C6-52D8-4D95-A12D-3F62091CE08F', '2AC0B2D2-F254-4F9C-98B9-995FA2BC8B2D', '8D83EEAE-A853-45AE-AB00-EA148BFAEEDB', '7a398c9a-91ce-4b59-ba5d-cc632a85d0c8', '62C2A601-B8EF-41C7-8704-BDA118D7D155', '08740265-3A67-4ECA-A7B5-F5ADF4C0003D', '9FC3D92E-3A0F-4FB8-858D-079F64FF267F', 'c678ed09-d9c4-41e5-a686-88927313ac8e', '3C83B0D9-18CE-4EFB-996D-82020CC0B635', '7da1fcad-145f-46c9-9ff3-504495a10524', '7634be48-bd3f-4439-b933-5c59408f968c', '166F8C46-CE21-48F4-820D-6AC636ED916A', 'a726696d-11a8-454b-84c3-bb18e2571a56', 'DC1D3A08-5110-4563-9F72-3D5DDC445FB0', '71B23C9B-D9C6-45DE-8B99-9BE65E7D5295', '8f148acc-0d1f-4af1-bbb3-be29254356c4', '7178dd21-3749-464d-aaf6-5b911e359f51', '19BA2B65-8E71-4F13-B77F-8393F3D4814E', '5ED22AF6-DF1C-4AFE-97AD-FD3522C99A04', '12B29104-3F99-4E0A-B393-6BB562BEC63F', 'DCCF6E32-0A4A-429C-A194-EE7674DFE573', '53d84696-21c7-4927-83d2-05fa1447463e', 'CA75AD76-5974-459E-888B-04EA1BF59153', '54b8cb55-2a5f-4ebd-bd72-4cb3519e4475', 'D05E00E2-8478-4963-894E-9F7A59FF326B', 'AB797A60-7F98-44CD-8AD7-F1ECB282F513', '7205E7ED-BFD6-421E-99E4-0D1C0A4CE2FA', '755DD778-F2BE-46AD-B0C6-D2EAEA23B9D0', '7eb6cf27-f5e5-4f6f-a342-99ca0656701b', 'BFF7DF9F-96A4-4A18-996B-9A1CB626E4C8', '8F659DF0-AE9C-4C6A-B2A0-65F091884367', '66ECEFD9-BC7E-44C2-B520-AC6FCE0FEE9C', 'E9F131C4-4210-4724-B7F6-0FEF753B9C6B', '5756BEEF-E542-4234-8877-911E3202C176', 'BC84F42E-3259-4AFB-919C-4EE84427394D', 'D79F2EEE-6A11-4141-B2F1-C0B5AF101167', 'D90B0A7B-9D86-412E-9D59-993CB1B3B81E', '45AB41DD-F8FD-4138-9342-1CBA8D90D500', '0494eeeb-764a-460b-98c1-4272fff5ce86', '793BA50E-E914-4751-9056-B0A77181718E', '05CE4CD4-F586-4DE4-B370-A29E2FBE7D16', '5DD8B9A1-52A4-403F-A354-26ABE3BDD945', '43D8FAF4-939E-450D-A031-1627D5795E1F', '39ED73BF-E20C-4BC3-9838-5496D1991469', '0E875B4A-1BDD-4456-A7C7-A0E7C02A209A', 'E71366BF-622E-4D20-A264-FF9A120FF584', '0FBB123B-E5D8-4FFD-883D-D99011538231', 'F025190D-121A-4DCA-8E3D-94B4C8C31825', '68408E65-FA8F-4DF6-A168-9B27630916B1', '27E1ABD0-9318-4901-8EB0-95174B3E87A2', 'd53add63-729b-4d46-81ef-801b55340866', '2DB80BD8-9B70-4A9C-A8AB-E15083415051', 'FA7451BE-46A4-45B3-AA40-A45B4782513C', '9E332D3B-7361-4574-9438-FB7C6DC2E7D6', 'B44B51D8-7E65-4A88-915F-DD1861D992D2', '7cd39329-df68-4575-924e-a7c95590b06b', 'FBE1EA16-AE3F-4088-B601-9D2B1A55C53B', 'D451D51C-0E41-4848-B5E2-7F037438C02C', '91D10D83-D52D-400E-A4FE-41E4DFB4F0F1', '91573EAA-15D9-4521-98A3-6FF3716C227C', '5F12EA55-0561-4897-9A21-D8F775441A41', '7c6ecfa8-991e-4241-bf34-9a368ae5b019', '5dd07bc0-9fbf-4c2b-9b39-00c22997678b', '6BDB40BD-E115-4185-B983-349A41D5C610', 'd2751e06-820c-4af1-a370-357a17023b03', '4bbd6263-3007-47b4-8772-83fcc2ab27e5', 'A516F310-409E-4018-A20C-9E07EA6BB5C6', '4951B540-0375-40D4-84C3-429A54E713AE', 'A99F7D88-7F22-439D-8F27-6E5A37A92B10', '5eaa098a-c257-42c5-9dab-b9403260eb8c', '6CDE5D72-1B5A-45E0-852B-7D16B8AE3904', '41A79150-0C18-4786-A59D-E9C77D9081E7', '80E4068F-3C45-40B2-8B8E-3325D2AA4AD2', 'acbf055a-4b2b-4378-ae02-db73af401c7a', '99DB857E-3C13-4FC8-9BDA-52B722F34B4D', 'CAE45B9B-9D8C-4E3F-BA20-26E260D20F70', 'EF46229C-9737-449E-B01D-128D2355C9F0', 'A569C016-4795-408C-900C-A92788539C8B', '808516c3-016d-4617-b15c-001e17dae0ea', 'BB4926A2-6127-45F0-A7A1-63FA54A319B5', '5D08BA0E-FEBD-4E1D-A89D-F9B4AAF16840', 'E320E1A3-6C1D-405A-A226-31B401B2AA11', 'A6DEB887-A27F-46FA-9EE8-EA9230531794', '192400B9-891A-4213-BBA6-85132918023B', '0cf59dc7-d427-435f-9a24-f2053a51ccae', '64354773-C8F5-44B8-B2A2-26F699FC9562', '9A273C7E-47E6-4E6F-9760-A739D493B292', 'EC4E7B84-EAEC-4810-B0E1-163F85C7AAE6', '37877CAB-4B82-417D-8E8E-77C66BBA29D4', 'A26047DA-18A9-40DE-ABD5-B828E7CCF84F', '61DB40C9-46C5-4A93-AAAC-2336AD109070', '86F99038-E41D-4CBD-A02E-0037DAF3385D', '390A241F-29B8-4E0D-B5C7-ECC7BB988FC5', '262FF919-E743-48A4-B0F8-EC16982D1E10', '72ED59FB-13DB-4C22-B170-C57DD6D9F5EC', '3F9AA0F0-2920-492F-812E-7DA5A1DC2B8B', '185C79A7-6E52-48A0-A761-ABCFC41CEF3A', 'B88EECD7-50A2-4EE7-8304-0E3D8F2063EE', 'C27E71FA-CB4C-4F89-88AB-EA1B985594FF', 'A09A085C-1CB3-4B47-8C0D-177164C4B188', '4D915C96-6467-40D0-B662-DC4A7DF8F617', 'F911A8AD-457A-468F-9814-43A3ADEB99A4', '6bf500a1-df44-4674-b847-3b3f0c66595a', '6d8b7d7f-1068-4399-8e40-6daa28fe1ac2', '0901068B-C94C-496D-9EA5-5E92ED1685C3', '1276A9F8-7CEC-4F50-86BE-A343C781B5CA', 'B96E6409-D81C-4860-B26C-78F73BF2BDDE', '319bab85-508f-42f3-8d65-108980e91093', '29567327-1DCC-4170-BD89-212B989B0149', 'E9BA14CD-80BC-4BBB-8259-CCD7AEC18972', '8A00FCCC-431A-486C-B590-8BA74D5A9E8F', '1C9A9974-EC47-4050-9AEC-CC02D1C7E62C', 'b917ab84-34c7-4388-afec-a6d15966010c', '8980F256-D58C-48E3-8E88-E1C95B8778ED', '6C98E78F-707D-404D-BA03-59BCA6309193', 'AF4E3A44-A8F9-43F5-B5C0-A008988FAE7D', '7D2DF70E-6121-4E45-840A-DF3A6DE2D2FB', '5D3D9F4A-7EF5-42DC-9D5C-9A1C95C3B66A', '1D28DF5B-123B-4E3D-892E-832691A63D78', '8ADA5FFC-E727-4623-9C24-AD5EF3806067', 'A67321E8-D8DC-47F3-86E4-D63AB12E1BC0', 'A84EAEAC-919B-4CE4-897F-9C10F509DC4A', 'EA91B836-9201-4A7D-8E05-A10AAB178A47', 'AD76272F-58B0-4066-B040-93784A9D436B', '7D15B316-9781-4AF7-B745-2169085DE864', '3CF90BB8-F9A1-4A2E-993C-186A12203B9C', '3A96D992-9E04-4407-8034-9877A391AC63', '78A31A50-934A-47DA-ABB2-D97D2A5BCAE2', 'CC24E4B6-738B-47D0-933E-6084B5D815DB', '2439F5C3-51AF-47AA-A757-8EFBADAA26F0', '13F78582-B266-4AA9-8613-52021DBDADAA', '59225190-BA66-459C-8B62-F01E069C22D1', '1ACAC63C-23D8-4B67-9E3A-9C599A86899B', 'cfc2febb-2ebf-4f25-b4ac-0875fb79aba5', '7E657F69-CB60-4D5D-A934-79A5EAAE103E', '99BCE25F-25DD-4817-BDAD-64AD833B57F9', '960B8820-5D12-4EB3-B425-1B2BC11A5E18', '4590659b-a6a5-401c-a313-d17f0b899eed', 'A74B66A2-3D2E-4F7B-829D-CBE0426E4345', 'ad656fdf-dca1-4f5d-96b4-ac834a5d2681', '6BC74999-E112-4287-8BA7-7C692F8A5FC2', '77986BA9-EC5D-4DB8-AE95-0BC3F7DCB8D8', 'e6fd31ba-8e16-43a6-9866-e9f2524e431c', '077082d4-9e13-4207-9e63-a97288d6d6c3', 'CB1C4C3A-A24A-429E-8068-05DFD83D600B', '7E15A4D3-AAC2-4EA9-B278-D2D1CC8089B6', '65CBAB7E-8E0F-4AB0-940E-98CD03B465A0', '148915a1-c04b-44ee-80a6-0bef982256c3', 'FF7CA58D-4CE8-4B55-9D4F-1FDB94005C0F', '47502315-14E1-4307-AE3E-7EA94FC15A48', '9f97c562-039f-403e-9130-780f7dd74de0', 'B4C97D08-822D-4150-8366-810835D15F73', '086B19DF-A359-4DA5-81E0-E5D9EF59543E', '721ecf97-583a-4b6a-aef1-89039fc96c95', '917A05A5-064C-4D91-B69E-CC3A48398DFF', '44E795D5-5888-48D2-A51C-4C7C5E27FC25', '61ddd52c-cdcb-4243-9f37-1bed224436e6', '179B110E-4E04-4BE0-9CC7-0483921BD3A7', 'ea00a037-3ca2-4bf5-a5db-a25d5f26c9d0', '56F8D737-0418-40D0-82D6-A6C1BA1E57DA', 'A93513DC-3A14-4324-B0E5-C45B880DB34B', '16e2fa56-9464-4cec-8d1a-6f2446ea5fa2', '9dad662c-0310-4b5b-a9a2-6a2a9ecf902a', '85A0F177-3B9A-464A-9F23-3FEA22CE600A', 'B213876B-17BD-4459-B43B-F699D2BAE0F6', 'D4FD8AD0-52DA-4BE2-A280-5065733E53D6', '023C5B65-F53C-4B72-9F66-620B4DA3C629', '41670B0D-6AE9-4D61-9FD4-7D70807D7F13', 'FD07BC75-360B-4C3F-9A77-49B712112285', '2CC0EAC8-67D8-4984-BE64-69E777DBFD49', 'fa06f63e-8579-457c-9d3a-341381ef9b9c', '8ba176dc-e543-4e77-ba01-e47435a20a67', '1ECF1DBB-69EA-4EC7-8D70-54C1C2162FD6', 'dd8136cb-26ee-4533-850a-d73cf24926f2', 'C7AA558D-3884-4D0C-8468-37514C9AE5E3', '739feab3-26fb-480b-944e-b5f4cae01759', 'BD54B390-D073-419E-9D66-9BA472254646', '9BF65748-046A-4B21-AA76-7B53461A545C', '7A32A1D7-8131-4429-896D-F741ECB3A4E9', 'DBD8412D-89AC-4147-A9BB-F158F5EE0118', '1304D3E4-FD8A-4664-A248-264E54E5EA11', '0B5AFF09-B532-4154-AC8B-C767F100B5AC', '12D0CFD2-8890-41B5-8A3F-B71D89BF1FE8', '5BF6444C-FD96-4C5D-BD11-B8AFE8FB8465', 'cfff2eb0-975c-4fb2-b383-056aaad66972', 'EC445FAA-A574-40BA-969F-C27AC4E53350', 'aefe4dd7-0604-4d0e-8e31-3aa9b3153960', '97DC2B01-2778-4009-9EBD-EDDF4C0BC914', 'FC9A6A6D-63EA-44CF-A039-29EEC5F29CA5', 'FD2C878D-2CBD-469E-9EB7-A6DBA6A25B3E', '3A797A45-E68E-4F06-8732-840457EC0563', '370ABA50-3E4A-421C-AB05-4005DA43A083', '6B77502C-A20E-4B5F-BCCD-CB4060B1E217', 'DF6F2240-09CA-44A5-8912-76AC7D82BA71', 'D329FE00-CD85-4A3B-AF78-9D2DC076421F', 'C672FD84-D401-42EF-91B0-7F42BA9B62F1', '83CACF57-9614-4610-838D-F0636CD8AE4C', '008d091f-6bad-4c63-8d35-37b615164dde', '7293d93d-b74b-4e30-8bc8-7879ad19948f', 'EA991606-F644-4685-8D38-F1F9877364A0', 'c386954d-9d84-4319-9898-2c43e16810ec', '7C48E38C-8880-4744-B422-C49124C398C2', '0f947e62-1131-4fff-a72f-7d79452def77', 'a776fc18-0e69-46ac-95ab-6d16ae9ef3f8', '5C0A59F6-1719-4113-9A46-25A97FA3066E', 'b2d8c6f0-cae3-4b99-8f68-e6b621b9f54a', '2FF31711-3518-482B-BEC7-7494F6C22C4A', '4988e219-7915-41fc-a9a6-1e96e47dbfb2', '2DD69090-931C-41EF-9DD1-9467CBB8F451', '65A78A54-56E8-4698-8C66-04354455691D', '3C654520-7C6D-41CA-9A4D-D5C97E094C5F', '869E98F1-A535-40D2-91E0-5CFB2D8AB885', '360F575F-729E-4D0E-A713-0FF6C216176E', '84f7791b-18a8-4653-a752-140dc3583106', 'FCC3BE94-1208-473B-B25C-F3C97F01754E', '96456E0A-FA42-4814-B11D-B18C4B92DF50', '4b15df34-7072-481b-b451-07635132d021', '4A44CA1E-8D00-464A-8A28-E031F9DED410', '73D5A0D1-A947-4DAD-8AAA-BA9F25CF71F6', 'AB1CE070-57BA-4C8E-956F-87A2EA5C6AAD', 'b630ae3a-f817-4cd0-a45a-17bd4def0883', '0C573A01-7280-4D26-9818-066BA1C6F330', 'fd942009-9dc1-44d1-b95f-8a43e98e61ba', '1289b7ed-008c-4933-8f44-379a87d6e612', 'ADB65AF6-11E9-4737-8BC8-81A4C071F8C0', 'ABC065B3-44F3-471F-89A2-109AAD6B137A', '07f49f94-949b-42b1-a8ce-ddf01c04a6af', '0762a67d-6bf3-41d7-8372-a97ad65ee4a9', 'db44f56c-7012-4894-a53c-634598325ac2', 'b1625193-fd96-4ad6-9769-dd934c3288c0', '79c5564c-c2b6-4e45-999c-5efd7aef5b4f', '8C9D9E24-BBFC-480E-9ADF-4CA7228E3C0A', '9e35c261-6851-4434-a315-04699b3bbc9c', '126BAE1B-3ECF-4D1F-82C4-7722EB51665A', '717BE78C-15DB-429D-851D-B2CE6ECF7B10', '28b5d1fd-4385-4106-bd6c-0dc6f048f04e', '8F51D0A8-BB8E-4518-BC3C-C47A57E68BBA', '064C86EE-CC50-4C9F-8E64-A89C0EC5909C', 'A76D4B2D-FC4E-4EF2-AE9C-59FF3D4EE45F', '66D2883C-ECFE-4CD7-9F5B-F1E8A954CB75', '4E9B9C5A-3C19-4C28-A7EE-A9BBC4BA455B', '5332B41E-31E6-4221-89DD-E569B3774E3F', '94087766-82ED-446D-9C63-76C453711134', 'f3dd3352-c8a5-4f6b-b2e1-4cf930b166d1', '9c1141e4-ad38-4858-b38d-66a22ccbb7fd', 'BFD4E8C2-EF62-4E32-AD62-F0063419B0A0', 'E8DE72B8-C33E-4383-953E-397B5DBCE64D', '4a5b0e4e-8172-4031-84f0-45e1e8f7a4b4', '103BD16E-D46B-4353-BDAD-56A7AF91D2E7', 'E2697577-E259-461E-B2C7-8600D825011E', '2b2362ec-2f8c-4e0b-a9c4-f9961b0a55fe', 'F3A73708-6EB3-42D7-975B-532BD3EFC469', 'c1040258-89f2-4462-bfb7-e4564bac8520', '65dd7f42-eee1-4bb9-a7fb-b96f24359708', '2e6be525-6d7e-4fca-862f-65a534231de3', 'F8F65C1D-4C5F-42A9-9449-30A674D8861D', 'D3261A8C-4203-4E2C-98E2-7FDF3684379C', 'E0045F8B-0784-429F-946B-25A889C2D4CF', '7408B390-F9FF-4338-B506-C7711BC51FF9', 'c5ff4fe2-f989-4f17-a947-3b32167d21cb', 'BAAAF840-628F-4A55-9A40-100377E9F701', '6F7734BD-C2E6-465E-80A7-D42DA7E0BD0D', '853d56db-e009-4cf7-99a2-f4ea87792d85', 'BC57652A-DEB9-46B9-BDB6-14D2E32E2E6E', '8e2e2804-e4de-4a9e-9ed3-31be6a2b087d', '2B7D26CB-77F5-4235-9D0C-A5EA0634B861', '556e9625-d4d8-4a20-a20a-05c9ef36af27', 'C82C5585-0F90-4A7F-B107-D6E1E92DC86D', 'BEB29D83-31AE-456E-80F0-C979EC0AE6FF', 'f480b4fc-5a72-4a88-9e8a-d12a7b7cf3af', '986E0BA1-6A37-4AEF-9C58-8ED4B36F6D78', 'E6D511FD-9F94-497B-BFC8-51A23D7424BA', '1673B93D-9378-4102-B9A4-04BBBDD3C27B', 'ee64e3b6-ef04-4e3c-ab6e-98d5a1bcc241', '96C18B8C-01A6-4E21-AAAE-E33A5BE38216', '1dc8b6ac-3c36-411b-b91c-35005038b5fb', '2A391FC0-B107-416A-845D-47A37BAB34AD', '84EA854B-37C8-43F8-86FD-CB8E878684F2', 'FC49142A-5B7A-4CC6-91FC-35C129746E1B', '16387161-2170-43c4-a5ac-a02d42b57ef1', '24ebc671-b32a-4734-b356-887336e25bea', 'cc9b1a8a-b403-491f-ba50-08838fd14d64', '724BDCED-6090-4704-8914-8A56259654AA', '57200e60-60e8-4c29-b40c-192f1430d8f7', '535A38D4-B2E0-4207-AC76-F2D6DF1CE8B0', '6016584F-5426-426C-84EE-4DC11ABDA096', 'CDD4B12F-1408-45D6-A838-27CF4C21B68F', 'CAFDE305-833D-4E76-9267-05A11620C4CC', '47502410-483B-468C-9C3B-02AFBADA2188', 'B72C4C1A-C86E-4C3F-A3FC-C4E4059091A1', '45B48127-DD39-426A-9370-74E3487F97B6', '329DF15E-AD26-4E9B-AE2E-F914DD0BBD28', 'eb671e1f-fe74-4c43-8691-a4594dd214bc', '216E1B6E-4A4C-401F-8777-CE8400B9A04D', '3D21C5A4-8F31-42A4-9073-5789FAC9BE7A', 'C97BBEE8-3A01-47B0-8B0E-1243C8F03A32', '3fb4dbf8-2047-4590-98e1-924dc5e06615', '736CC253-6E81-420E-B543-E1D8DD1DE0DF', '669dd9fd-3997-48e3-8bb3-b80d0d038e7a', 'be88d86d-75dd-4f50-8895-adf9d0fccd16', '8ac6c300-da7d-4771-928c-fc889175a79b', '6AAA2CBE-BDAA-49C7-BAB8-CA9CA9C207B1', '7092BFCC-59F4-4933-A92C-BFFE87024C2F', '1294eb6d-b661-4870-871c-ac64e7c1ea81', '7a96b27c-30e4-4b6f-a6a0-161d0102dee1', '1d3a40ec-d19d-4fe8-bd91-3a36aa6fa470', '768E0779-FC62-48A4-AFB9-9BBE7A28ACBE', '3652DE04-429E-414D-A935-14928CA7F31E', '85730609-E497-45D2-B2B9-14821EE14986', 'c6f13919-451c-4359-b313-ce1c183f9c6d', '46F2221E-BB2A-4292-BCD6-F576C477889F', '761260df-cfca-40e5-8104-d7aa6c0263e3', '885E1330-CFE0-4D39-8EF7-F67FD18E7941', 'CC66BDFE-5B27-44D8-B851-75A3BC2E4D77', '23FA5557-51DA-4400-AD3D-64D1413E8ADC', '88ECC23E-4B8B-4FB4-8785-B4C96025A2A6', 'f05356d7-3c93-4cdc-b4f0-b670f3043f78', '055600D0-1571-4A3C-96BD-FBD2DB826123', 'f62f872d-6004-47a2-b501-f07e03e7f69f', 'AF853883-CEAE-44C8-B772-005A06BAAA2F', '0a4fc996-5364-4dbb-99e1-d9022e72b6f1', 'b845ef48-4a64-458b-bbc3-ec67e75f32a3', '51B59EF0-8E76-49C9-A804-14E556C94F31', '8a85b399-1137-429b-8601-02cf44f5d4f6', '929DF21D-9631-4937-A4C1-AB59B0EE28BB', '470DB047-6BD4-45DC-9C42-5E192F66E634', '33ae72c3-6d0d-4744-aa8c-6a0cf98210e1', '9768d9a8-2337-49c6-87a5-2ad922b28dba', '8e5427b8-dc0e-42be-ba89-dc7580093a91', 'E3DD1F78-6E4B-4F63-B18D-29D8CD0613F5', '0f064242-10d6-4979-b023-ced2f33841b9', '4de68d81-4642-4144-b388-4db1a9889b53', '23645417-405A-48BA-920C-BC855015FBAF', 'd7393772-1105-45fb-a846-498dcd095058', '71665BF8-FFB3-491F-A491-E13550814642', 'a5214c0a-8da7-41f5-9c5c-16f0d7fba457', 'b1a3fe43-46f3-48fa-87da-8bba6a9b4dbb', '26308a33-01f6-4c83-bc52-7d1bc0d957f8', 'CB20EE22-8515-4AAC-BBB2-CF0BF03D819D', '3C85A7B0-C744-44CE-A419-0F9022559004', '00DD2EF2-AF4A-49F9-9336-BBBF40C27B8A', '5F1F32BD-6579-474B-9B14-ECAA39EB910B', '4d51f0ff-08ff-4bad-a7da-f2787fad234a', 'D61AC31F-C290-4175-B1E8-63D82488CF36', 'AFB55542-076B-42F6-81F3-B2B508A6AAF3', '38f83584-6e10-41ce-a0f6-d30f8f541966', '33814945-b442-4a2d-a162-a2000864a39c', 'd9ec5610-d222-4459-8a42-bb52e0175ce9', '91cb94a6-9669-40f2-a543-9df0ff4fa923', '91b45aa7-7d8b-4b30-94e6-239a9952602a', 'd25b509d-f918-4184-b5f8-b2e2d4721684', '1757ABAA-AC34-4A2F-A9A1-2CA493646430', '38372684-7197-414b-aeae-7c8cf9a96485', '5c42ef0b-77c9-4e7c-b0c9-72a6c1c9868a', 'f9d8318a-d6e4-40f4-a247-2d83691cfd2e', 'ADD56081-434A-41CE-A25F-5FE189E186F1', '1B1649E9-1427-447F-960E-03570F0BB45F', 'E4CB8A20-5A21-4734-9F02-DCE5E0E5D07F', 'DCD8D054-06CE-4370-BF5B-31E872C65A58', '1FC60254-7B83-4FE7-9D21-A89B01C56BC6', '7d7668e9-3752-4f91-af22-293f8f7ffc19', 'C2FCA3CA-A8A7-464F-8411-0F6F9529B889', '0337FF4A-CB19-489C-A6FC-6A52A77ABD06', 'd22fd0ca-cb04-4235-94c1-66076a553846', '3D679C7D-3755-4B2B-B48C-A981AE9087A4', '5DBBD6A3-E6C2-45EA-BC6D-86375D98DD44', '26AAE936-39D0-4C4C-A07C-87EA9E9D116D', 'E80788CC-B2C4-4D24-9CCD-B9FE3F6597D6', 'a96965d8-9638-457a-9bdf-5706394d1354', 'a0921826-53d1-4c62-8d3f-e1117dfda843', '50802005-86c2-4f43-9356-74f7dd177032', '4c196006-c6e2-4d49-ba68-fe04d9100339', 'BF1F1765-B4AB-4C2A-A1A3-BD5CEA11D9FF', 'c8832db5-2f2b-43ba-95cc-5a07b543fe03', '0465ED90-BACA-4C61-92A8-BB70BF105DB9', '4015191D-6E46-4CAA-B05E-8621780CFB73', '9188aa0a-0c92-41af-82de-13a803df74b6', '9C0A3FE7-9F19-4922-A742-2A76F0C29D4D', '00be3df7-ab64-4ceb-804d-284db2d73815', 'E0A5DF5E-CD8C-479C-846F-E40C1EBAD0C1', 'B5613661-220A-45C6-8F39-D5A43FDC3F1B', 'D0946106-7F40-41D3-9EF6-ADFCDE769DAD', 'E0C00718-9381-4249-A60A-2F5EDE775FCB', 'D40D8612-AA74-4883-9157-3042AA5797F0', 'D19E6B5D-6E1A-4C1C-B48C-A30B179DF3F3', '8B037581-08A7-481B-B8DB-5B28612A4951', '2F487CD3-B059-40AE-BA60-D2F88414FBDA', '35665D16-69A2-443F-A49E-FD5FBB0A1CA9', '95E52FB2-E931-4954-A491-CE110D21FAFE', 'e3b31408-331c-406d-9fed-ea6bea4a5424', '79d18a41-e4cb-453b-81a6-995959cff4e8', '5ba97bf9-7660-46a0-841d-2cc6d6494be1', 'B21722D6-630F-44DF-8578-EC1E29EDF7CC', '20A66E09-E48C-4A8A-B75B-67E153BD2F0C', 'F8758D03-E63B-428F-8F11-1A8A6F6A6516', 'F4BD0683-0C02-4C9A-B535-AE2C1CC82BFD', 'F3D40D8E-2A90-481D-A536-7393C30CD27F', 'E544A578-B74D-479F-B8DB-4020031517B5', 'E1AE1067-8448-47B1-8E60-CE77FE71AAA4', 'E18C4306-5E27-4CCE-969B-83D3487D5AD5', 'D35C7081-F013-4053-9F58-24C063C9DDCE', 'C88CDED9-4DC7-429D-8C4E-657E72CDA2E5', 'B4650761-EBD0-4D0B-801E-81FA27EC42F2', 'AD51D1FC-3C95-4215-8B3A-5D6209853512', 'AAFA9691-DC62-49CD-8B90-2848A9FABBEE', 'A40700DE-56ED-4BE3-B1DE-8976E81A9C75', '8F406559-8499-4143-A2F9-F2A080C4232F', '8A7CCB4E-25F3-40C9-8454-A3CBA26F31C7', '87B96787-2842-4C80-A8F9-E4BD9E37FFEF', '8433B6F3-4E96-4DD8-B31B-3327272B8F6B', '7C727602-B068-4E68-A460-9493F70E939C', '727C02C6-5D19-4382-ADDC-453C0CA56A9F', '60D99BF7-41C8-41FA-AE36-333F36827742', '5FB3D3DE-B35F-4CD3-8604-E95DB4782369', '5D0039B5-ABBC-454D-8BB1-10A330042FFA', '5C5FB635-8D90-4275-B321-DA360B556A18', '5484702B-9A4F-4214-AED8-6F244B409C38', '4AE1CECC-1646-40D1-954B-B0D8FF16A82D', '41E4B852-D3F4-4CFB-B5EF-B79CA25C1659', '3D1C8C5E-083C-4525-AB8D-8F7478181488', '3631280C-84EF-4891-A564-2263CFF78F18', '2F5C785B-EDFE-43DD-8DF1-9622FAD6BE3D', '24CF810D-9633-49F4-9F4B-F8AB8BD5ED03', '247EF179-6D68-45DF-BA60-4F63003FD216', '1D3C7E27-1C10-4E3D-95CD-86B9699E07EA', '1CBFA40D-3624-4B8B-851B-AFFEAB078E12', '161142B1-CC59-4DFA-B100-2316B0C62E80', '146D15A8-1CBD-43D3-8F4C-F568952F7A1F', '13316E84-8F98-48CA-86EA-5D01E9E61398', '0F460273-CCD7-4886-A1A4-1D5C96F97CC1', '0D749881-0F67-449E-97C5-1CF7F56915DA', '09A168BB-CF9E-4849-8FB9-088BFFBDD2C5', '079FE03E-AAC0-4627-9F7A-D83B91C6F675', '02F23B27-8596-4892-91AD-375F6F315273', 'FF2369C8-ABF1-4455-B0F3-9525BBE156AE', 'FCEBF5D4-BF2A-4679-8F66-44580CD97657', 'FC696FF3-CD0A-4AE2-9D42-E03B143A62C8', 'F20C53EB-4832-452D-8124-20B6E327D85E', 'EA1B9A54-8AEC-4C69-8F88-DCB15742A70F', 'E45F7274-52BE-4417-8F5F-BC59996AA583', 'ABA03842-4D52-4881-95F8-7C939CDDF916', '9D433B73-C4DC-4514-9C61-556D01C10173', '96C4F9BA-F264-4650-A520-251802E50807', '955924C6-6B9A-4435-B85B-03806104E161', '81D4931F-3643-471E-948E-E7763DB67AAA', '6E78B4D1-0462-40D5-8B8C-3C86D97B99DB', '6A2CFDAC-6742-4F0F-9378-432D6236D3D3', '66142156-73EF-4AC3-9E30-99D2F4ADD1F8', '64C7CD32-7688-491C-A063-9E83CB072B19', '62BE1BA9-2C4D-424F-B38C-0C15FA01B0DF', '541E54AA-76AF-4FE2-86CE-17A897DFBF88', '33B6716D-3318-43BA-A6B3-E4AA52A75185', '3014274C-C691-4D0F-BE1F-BC85747E8ADB', '0EC8716C-0E04-4AFA-82C6-94A908244A0B', 'CA1E2FC5-8809-4AF9-B05B-BF3D517BEF7A', 'B52EB6B2-3065-44B3-974C-CD5649211733', '9413088B-3954-422D-ACBA-B6B3744466D6', '807A9B76-5260-4EB7-A50D-F7E92E084628','8855e05b-7e38-4298-942c-afe5f4157e9e') AND ([s].[OnShelf] = CAST(1 AS bit))",
        "output": "SELECT FROM Speech"
      }
    ]
    
  4. Run test TestDbSignatures in test/Elastic.Apm.Tests/DbSpanNameTests.cs
  5. Check test duration

Code/PR where this issue first introduced

https://github.com/elastic/apm-agent-dotnet/pull/1657/files#diff-70b8cfeedf4e7593846932c85a11f77ae8e515c6bf644af3d41b4bd8b46eb4abR100

Possible fix

Because for this case, the result span.name would be SELECT FROM Speech, if that’s what we expected, maybe for large SELECT columns FROM table WHERE column IN ('1', '2', ..., 'N') sql query, we can truncate IN ('1', '2', ..., 'N') before we go to parse span.name.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
d-zieglercommented, Aug 10, 2022

Found the culprit in the Scanner.cs code. The problem here lies within the Peek method, as it uses _input.ElementAt(_pos) instead of just getting the char at the index by using _input[_pos].

Measuring the time of the OP’s query with ElementAt, the signatureParser.QuerySignature method measures something around 421ms. By using the direct index access, the duration goes down to 2ms.

The duration of my own query measures ~1900ms, with the change its down to 3ms.

2reactions
gregkalaposcommented, Aug 10, 2022

Thanks for the fix @d-ziegler - the PR with your fix is merged.

Additionally, I also opened https://github.com/elastic/apm-agent-dotnet/pull/1782 - that’ll add the sample input sql query to our tests and also adds a benchmark to measure this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is selecting all resulting columns of this query faster ...
It's true that selecting more columns implies that SQL Server may need to work harder to get the requested results of the query....
Read more >
Chapter 4. Query Performance Optimization
In the previous chapter, we explained how to optimize a schema, which is one of the necessary conditions for high performance.
Read more >
sql - Which is faster/best? SELECT * or SELECT column1, ...
One reason that selecting specific columns is better is that it raises the probability that SQL Server can access the data from indexes ......
Read more >
Query optimization techniques in SQL Server: tips and tricks
In this blog post we will show you step by step some tips and tricks for successful Query optimization techniques in SQL Server....
Read more >
Basic SQL statements and functions used in QMF queries
The following figure shows an example of a long object name that spans two lines. The name is qualified with an authorization ID...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found