{"id":22938412,"url":"https://github.com/jacraig/holmes","last_synced_at":"2025-08-12T18:33:20.261Z","repository":{"id":65535102,"uuid":"91730324","full_name":"JaCraig/Holmes","owner":"JaCraig","description":"A library to help with analyzing a database. It then make suggestions for improvement or can apply them automatically if you like to live dangerously. For the most part it reports recent expensive queries, missing indexes, overlapping indexes, and unused indexes. However it can be expanded upon to add your own analyzer.","archived":false,"fork":false,"pushed_at":"2024-10-29T23:48:33.000Z","size":20869,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-30T04:55:19.386Z","etag":null,"topics":["analyzer","database-analysis-library"],"latest_commit_sha":null,"homepage":"https://jacraig.github.io/Holmes/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JaCraig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-18T19:29:00.000Z","updated_at":"2024-10-29T23:48:35.000Z","dependencies_parsed_at":"2023-09-26T04:58:02.404Z","dependency_job_id":"fb14028d-5843-4371-8343-f224d2823ce1","html_url":"https://github.com/JaCraig/Holmes","commit_stats":{"total_commits":72,"total_committers":4,"mean_commits":18.0,"dds":0.6805555555555556,"last_synced_commit":"ea2a7a671eb12775750fd89a671f6bba2e8f98fa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FHolmes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FHolmes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FHolmes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FHolmes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JaCraig","download_url":"https://codeload.github.com/JaCraig/Holmes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229700186,"owners_count":18109929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analyzer","database-analysis-library"],"created_at":"2024-12-14T12:17:51.434Z","updated_at":"2024-12-14T12:17:52.091Z","avatar_url":"https://github.com/JaCraig.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Holmes\n\n[![Build status](https://ci.appveyor.com/api/projects/status/w95i5th94ayc3f6q?svg=true)](https://ci.appveyor.com/project/JaCraig/holmes)\n\nHolmes is a database analysis library. It scans a database and returns suggestions for improvement. Supports .Net Core as well as full .Net\n\n## Setting Up the Library\n\nIn order to use Holmes, you need to start by wiring it up on your ServiceCollection. However this takes just one extension method call:\n\n    serviceCollection.AddCanisterModules();\n\t\t\t\t\t\nWhen this is done, Holmes is ready to use.\n\n## Basic Usage\n\nThe main class of interest is the Sherlock class:\n\n\tvar Results = Sherlock.Analyze(new Connection(...));\n\t\nThe Sherlock class contains one function which is Analyze. This function takes a Connection object defining where the library should be pointed. It will then, based on the provider specified in the connection object, run any analysis classes that it has and returns a list of Finding objects. The Finding class looks like this:\n\n    public class Finding\n\t{\n\t\tpublic string Fix { get; }\n\t\tpublic IDictionary\u003cstring, object\u003e Metrics { get; }\n\t\tpublic string Text { get; }\n\t}\n\t\nThe Text property contains the explination of what was found, the Metrics property contains the data that was returned by the analysis object, and the Fix property contains the SQL command that can be used to remedy the issue. Note that not all analysis classes will contain a suggested fix. This is optional where as the other two properties will always contain some information.\n\n## Adding Your Own Analyzer\n\nThe system a couple of built in analyzers:\n\n* SQL Server\n  * Recent expensive queries\n  * Missing indexes\n  * Overlapping indexes\n  * Unused indexes\n  \nHowever you can easily add your own analyzer by simply creating a class that inherits from IAnalyzer.  The system will then pick it up automatically and run it as well. For simple analyzers there is also an AnalyzerBaseClass that will simplify the process of setting up your analyzer. The IAnalyzer interface itself is rather simple though:\n\n    public interface IAnalyzer\n    {\n        /// \u003csummary\u003e\n        /// Gets the factory the analyzer supports.\n        /// \u003c/summary\u003e\n        /// \u003cvalue\u003eGets the factory the analyzer supports.\u003c/value\u003e\n        DbProviderFactory SupportedFactory { get; }\n\n        /// \u003csummary\u003e\n        /// Adds the query the analyzer needs to the batch.\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"batch\"\u003eThe batch.\u003c/param\u003e\n        /// \u003creturns\u003eThis.\u003c/returns\u003e\n        IAnalyzer AddQuery(SQLHelper.SQLHelper batch);\n\n        /// \u003csummary\u003e\n        /// Analyzes the specified connection's source database.\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"results\"\u003eThe results of the analysis.\u003c/param\u003e\n        /// \u003creturns\u003eThe list of suggestions for the database.\u003c/returns\u003e\n        IEnumerable\u003cFinding\u003e Analyze(IEnumerable\u003cdynamic\u003e results);\n    }\n\nThe SupportedFactory property is the DbProviderFactory that this analyzer should be run against. All analyzer queries are batched together by the system and run at once. As such there is an AddQuery function. With this function the system passes you the SQLHelper object it is using to batch the various queries. The one method on that you will probably use is AddQuery. The only other method is Analyze. This method recieves the results of the query as a list of dynamic objects. The names of each property is the same as the result set of the query you specified previously. In turn you should return a list of Finding objects.\n\n## Installation\n\nThe library is available via Nuget with the package name \"Holmes\". To install it run the following command in the Package Manager Console:\n\n    Install-Package Holmes\n\n## Build Process\n\nIn order to build the library you will require the following:\n\n1. Visual Studio 2022\n\nOther than that, just clone the project and you should be able to load the solution and build without too much effort.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacraig%2Fholmes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacraig%2Fholmes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacraig%2Fholmes/lists"}