Confluence Docs 3.0 : How to Search Confluence for Uses of a Macro This page last changed on May 08, 2009 by jlargman. ### Illegal Search Terms Several terms are illegal to use when searching Confluence, like : or {. If you search for just the macro term, you're likely not to get the right search results. For example, searching for 'usage', which is the name of a macro but also a common English word, will not yield an accurate count. ### Query the Database If, for example you want to search for the uses of the `usage` macro, you can search the database:
| For large instances of Confluence, searches across the entire bodycontent table of the database might be expensive. You can try this on a test server.
| You might want to use the SQL Plugin to automate this, or better yet the Macro usage stats plugin. Note that these are third party (unsupported) plugins.
    SELECT * FROM BODYCONTENT WHERE BODY LIKE '%{usage}%'
If you want to get the last users or the creators of the pages where the `noformat` macro is used, you might run:
    SELECT CREATOR FROM CONTENT WHERE CONTENTID IN (SELECT CONTENTID FROM BODYCONTENT WHERE BODY LIKE '%{noformat}%') GROUP BY CREATOR
    SELECT LASTMODIFIER FROM CONTENT WHERE CONTENTID IN (SELECT CONTENTID FROM BODYCONTENT WHERE BODY LIKE '%{noformat}%') GROUP BY LASTMODIFIER
### Logging Uses of a Macro This information won't tell you how often a macro is invoked - rather how often it appears on pages. For counting how often it's invoked (and measuring the time it takes to invoke it), check Identifying Slow Performing Macros. ### Counting the Incidents of Invoked Logs You can then grep the logs like:
    grep -c "{usage" atlassian-confluence.log

Document generated by Confluence on Nov 05, 2009 23:34