Given the following NRQL query:
SELECT * FROM AppPerformance WHERE app LIKE '%stackoverflow%'
Would this other query be cheaper in terms of performance and cost?
SELECT * FROM AppPerformance WHERE app = 'stackoverflow'
See the cost and performance of NRQL queries in New Relic depend on various factors, including the amount of data in your New Relic account and the query complexity. In general, using a more specific query is likely to be more efficient and cost-effective than using a wildcard pattern, especially if the wildcard pattern has the potential to match a large number of records.
In your case:
SELECT * FROM AppPerformance WHERE app LIKE '%stackoverflow%'
uses a wildcard pattern to match any value of the app
attribute that contains "stackoverflow" anywhere within it. This could potentially match a wide range of records, and the query may take longer to execute and consume more resources.
And SELECT * FROM AppPerformance WHERE app = 'stackoverflow'
is more specific, as it only matches records where the app
attribute is exactly equal to "stackoverflow." This is likely to be more efficient and cost-effective because it reduces the number of records that need to be scanned.
So, in terms of performance and cost, the second query likely to be cheaper and more efficient. It's always a good practice to use the most specific query that meets your requirements to optimize performance and reduce costs.