Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6937237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:20:15+00:00 2026-05-27T12:20:15+00:00

I started teaching myself SPARQL yesterday, and I’m practicing against dbpedia. I’m trying to

  • 0

I started teaching myself SPARQL yesterday, and I’m practicing against dbpedia. I’m trying to retrieve a list of all footballers who have played in two clubs near to the specified destinations (i.e. Swansea and Oxford). I have the following query, which works but is very slow:

SELECT ?player ?team ?team2
WHERE
{
  :Swansea geo:geometry ?point1_1 .
  ?team dbpedia-owl:ground ?ground .
  ?ground geo:geometry ?point1_2 .  
  FILTER (bif:st_distance( ?point1_1, ?point1_2) < 5)
  ?player dbpedia2:clubs ?team .

  :Oxford geo:geometry ?point2_1 .
  ?team2 dbpedia-owl:ground ?ground2 .
  ?ground2 geo:geometry ?point2_2 .
  FILTER (bif:st_distance( ?point2_1, ?point2_2) < 5)
  ?player dbpedia2:clubs ?team2 .
}

My problem is that the query often times-out when run on dbpedia’s query page (see http://tinyurl.com/d9pkluq). Is there any way to optimise this query? If I enter more towns, or specify a larger radius to search, I would still want it to run without timing-out in dbpedia’s query page.

Thanks for any help you can provide!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:20:16+00:00Added an answer on May 27, 2026 at 12:20 pm

    Your query is a perfectly valid one, and in an ideal world, the SPARQL query engine that processes your query would run in in the optimal way. However, many SPARQL implementations haven’t got that good query optimisers yet so you often have to optimise the query yourself. Typically you do this by re-ordering parts of the query.

    One common technique is to try to order the graph patterns in your query so that the number of query results is reduced as soon as possible. Bear in mind that each graph pattern will be run against each and every match of previous patterns. You can think of your query as a series of nested loops; you want to avoid doing a lot of operations in the inner loops.

    In your query example, you could for example reorder it as follows:

    SELECT ?player ?team ?team2
    WHERE
    {
      :Swansea geo:geometry ?point1_1 .
      ?team dbpedia-owl:ground ?ground .
      ?ground geo:geometry ?point1_2 .  
      FILTER (bif:st_distance( ?point1_1, ?point1_2) < 5)
      ?player dbpedia2:clubs ?team .
    
      ?player dbpedia2:clubs ?team2 .
      FILTER(?team != ?team2)
    
      :Oxford geo:geometry ?point2_1 .
      ?team2 dbpedia-owl:ground ?ground2 .
      ?ground2 geo:geometry ?point2_2 .
      FILTER (bif:st_distance( ?point2_1, ?point2_2) < 5)
    }
    

    So, instead of looking for another town and a potentially very large number of combinations of towns, clubs and players, limit the choice of second teams you look at by constraining it to only ones that “interesting” players have played for. I’ve also added a check to avoid it matching the same team for ?team and ?team2.

    I can’t say for sure if this will make things better in your case, this depends very much on the exact DBPedia endpoint you’re running against. But this is the sort of optimisations you can experiment with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started teaching myself C# and Asp.net. I am trying to build
Good day, I've just started teaching myself VB.net. I'm trying to create a simple
I've been teaching myself C++ and started creating a list organizer to work on
I am currently teaching myself jQuery (started yesterday) and I'm stuck already.. I have
I've recently started teaching myself the standard template library. I was curious as to
My disclaimer here is that I started teaching myself C++ about a week ago
When I was first started teaching myself programming, after finishing a tutorial I would
I'm teaching myself CIL and have been doing ok so far (just really started
I have started teaching myself about the Android NDK and I have followed this
I just started teaching myself Linq to SQL today. I hardly know anything about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.