Skip to main content

SQL Search

The SQL Search screen lets you search for any SQL statement text using fuzzy matching logic.

Use cases

This can be useful if you have a statement from another source such as your development IDE, a log file or perhaps another monitoring solution and wish to find that statement in DBmarlin wherever it might have run.

In the majority of cases, there will be differences between the SQL text you see in DBmarlin and the text from the other source. These could be minor formatting changes like line breaks, tabs, spaces, quotes, backquotes or doublequotes or could be more significant, but either way, an exact string match won't work, so we need to utilise a form of fuzzy matching.

Searching

Enter the search text into the box and click "Search for Statement". The results screen will look like this. You can see columns showing which Instance the statement ran in, the Statement text and the Similarity.

DBmarlin SQL search screen

Search results

Search results are sorted by Similarity and we return up to 500 matches. Similarity is a score out of 100 indicating how close of match it was to the searched for text. Only an exact string match including formatting and white spaces will score 100%.

The search will be across all statements that have been collected from all instances. This includes statements from:

  • Activity screen statements which were collected by active session sampling.
  • SQL Statistics screen statements which were collected from
  • Grouped Statements which have had their variables replaced by a '?'
  • In the case of SQL Server it also includes Batches and Grouped Batches.

Clicking through on a search result take you to the Statement screen for that Statement where depending on the type of statement, you may be able to see it's Activity, SQL Statistics and Execution Plan.

Fuzzy matching

We use a fuzzy matching algorithm to identify similar statements. This works well where a high percentage of the statement text matches but won't work well if you try to only match a small portion of the text. One limitation is that it only matches on complete words. For example searching on "RIDES" will match SELECT * FROM rides but searching on "RIDE" would not match. It is case insensitive so it doesn't matter if you use upper or lower case in your search.