• User Guide
  • API Documentation
  • Tools
  • Developer Guide
  • Support
  • User Guide
  • How-To Guides
  • Debug SPARQL Queries
Show / Hide Table of Contents
  • Getting Started
    • Core Concepts
    • Hello World
    • Reading RDF
    • Writing RDF
    • Working with Graphs
    • Typed Values and Lists
    • Working with Triple Stores
    • Building SPARQL
    • Querying with SPARQL
    • Updating with SPARQL
    • Formats Supported
    • dotNetRdf Assembly Signing
  • Going Deeper
    • Exceptions
    • Event Model
    • Equality and Comparison
    • Utility Methods
    • Extension Methods
    • Namespace Mapper
    • URI Factory
    • Node Factory
  • Storage API
    • Triple Store Integration
    • Servers API
    • Transactions API
  • Storage Providers
    • Allegro Graph
    • Blazegraph
    • Dataset Files
    • 4store
    • Fuseki
    • In-Memory
    • Sesame
    • SPARQL Query Endpoints
    • SPARQL Query and Update Endpoints
    • SPARQL Graph Store Protocol
    • Stardog
  • Advanced SPARQL
    • Result Formatting
    • SPARQL Datasets
    • Full Text Querying with SPARQL
    • Advanced SPARQL Operations
  • Ontology API
  • Inference and Reasoning
  • Dynamic API
  • Formatting API
  • Configuration API
    • Graphs
    • Triple Stores
    • Object Factories
    • Readers and Writers
    • SPARQL Endpoints (Deprecated)
    • SPARQL Clients
    • Query Processors
    • Update Processors
    • SPARQL Datasets
    • SPARQL Expression Factories
    • SPARQL Operators
    • SPARQL Optimisers
    • Full Text Query
    • Reasoners
    • Storage Providers
    • Static Options
    • Proxy Servers
  • Handlers API
  • JSON-LD API
    • Expansion
    • Compaction
    • Flattening
    • Framing
    • Processor Options
    • Error Handling
  • How-To Guides
    • Debug HTTP Communication
    • Debug SPARQL Queries
    • Load OWL
    • Load RDF from a File
    • Load RDF from the Web
    • Minimize Memory Usage
    • Reify Triples
  • Upgrading to dotNetRDF 3.0
    • Key Changes
    • Global Options Changes

Debugging SPARQL Queries

In-Memory Queries

If you are using our in-memory SPARQL engine then you can attempt to debug why your queries are not working by using the ExplainQueryProcessor to try and figure out what is happening with your queries.

It is important to understand that explaining query evaluation will substantially impact performance so if you are trying to debug performance issues this is not the way to do so.

You can create this like so:

//Assuming you already have a dataset you wish to use in the variable ds
ISparqlQueryProcessor processor = new ExplainQueryProcessor(ds, ExplanationLevel.Full);

Once you have the processor you run your query like you would normally with a query processor i.e.

//Assuming you have a query ready to run in variable q
Object results = processor.ProcessQuery(q);

This will result in your query being evaluated but also explanations of the query level being printed to Console Standard Output and Debug Output. These explanations will include useful information like how many results were found at each stage of the query and can help you see why you have no results

Remote/Native Queries

Debugging queries against remote endpoints or native SPARQL provided by a IQueryableStorage is somewhat more difficult.

For IQueryableStorage check the documentation of the store you are using to see if they provide any query debugging tools that you can use.

If not the best way to debug queries is to follow the following method:

  1. Break your query down into its constituent parts i.e. individual triple patterns
  2. Run each triple pattern to verify that it will return results
  3. Start to build your query back up in small chunks i.e. individual graph patterns
  4. Run each graph pattern to verify that it will return results
  5. Start adding back in the FILTER and joins to your query
  6. Run each form of the query to verify that it will return results

The general idea is to verify whether the blocks of your query actually return results and identify what block(s) are preventing your query from returning a result. Once you have done this you can start to adjust your query to produce some results.

  • Improve this Doc
In This Article
  • In-Memory Queries
  • Remote/Native Queries
Back to top Generated by DocFX