You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org
User:AKhatun/Wikidata Subgraph Query Analysis
Analysis on Subgraphs in Wikidata showed how large each of the subgraphs are in Wikidata and how connected they are. This page shows the results from analysis on the queries that relate to these subgraph. The questions that needed to be answered were:
- How many(percent) queries access each subgraph?
- How many queries access multiple subgraphs at once? i.e, how much overlap can we expect in subgraphs?
- How long do these queries take?
- How many user-agents access each subgraph? How many of them access lots of subgraphs, or are they confined to a small set of subgraphs? Do some of them dominate queries in multiple subgraphs?
- Are there chunks of similar queries in these subgraphs? i.e, how diverse the queries in each subgraph are.
We define some parameters to identify whether a query touches on a subgraph based on the items and properties a query uses. Some queries may even touch on multiple subgraphs. See more on what a subgraph means here. Note: Subgraphs have overlaps.
The parameters that define which subgraph a query belongs to are:
- If the query uses the subgraph's Qid. Example: Q5 containing queries are part of Q5 subgraph.
- If the query uses items that are
instance ofa particular subgraph.
- If the query uses items that occur 99% of the times in a particular subgraph.
- If the query uses properties that occur 99% of the times in a particular subgraph.
- If the query uses literals that occur 99% of the times in a particular subgraph. The literals can occur with or without language tags. Both versions are compared to check for match. Note that whole literals are matched in queries and Wikidata. Queries that ask for partial matches, using regex for example, are not included. The assumption is that such queries are more likely to contain other items from the subgraph and are caught anyways.
The following analysis uses Wikidata dump of
20211101 and WDQS public SPARQL queries of 10/2021 unless otherwise stated. All query related numbers below are monthly values.
Query count and time
- All queries here refer to queries with status code 200 and 500, i.e correct queries, successful or time-out.
- WDQS receives ~220M queries a month.
- Total query time for all queries for a month is ~16,000 hours.
The table below lists the top 50 most queried subgraphs with subgraph size and query time information of
11/2021. A breakdown of what caused the match is also present, which corresponds to the parameters mentioned in #What are subgraph related queries. It also ranks the subgraphs by size, query count, and query time consumed. A more complete list containing 341 subgraphs, that form ~90% of Wikidata triples, is available here: [csvlink|all_subgraph_data.csv]. The difference between values from October and November is shown in the next table for comparison purposes. In some places, the query count percentages differ a lot.
|Subgraph rank by size||Subgraph rank by query count||Subgraph rank by query time||Subgraph||Subgraph label||%of triples||%of entities||Days to recover (4.77M rate)||Query count||%count of all queries||Query time (hr)||%time of all queries||Avg time/query||%count of query from Qid||%count of query from instance items||%count of query from items||%count of query from properties||%count of query from literals|
|7||7||3||Q4167410||Wikimedia disambiguation page||1.354||1.464||38||3,292,873||1.728||765||4.982||0.836||0.164||0.192||0.472||0.0||1.163|
|26||10||29||Q484170||commune of France||0.179||0.048||5||1,934,902||1.015||70||0.455||0.13||0.024||0.869||0.085||0.115||0.01|
|19||11||22||Q13406463||Wikimedia list article||0.249||0.355||7||1,766,742||0.927||117||0.765||0.239||0.034||0.372||0.628||0.0||0.137|
|242||32||8||Q14204246||Wikimedia project page||0.008||0.033||0||498,708||0.262||548||3.572||3.957||0.026||0.19||0.038||0.0||0.064|
|72||41||23||Q86850539||Whitaker's Latin frequency type C||0.047||0.011||1||436,103||0.229||95||0.622||0.788||0.0||0.0||0.0||0.0||0.228|
|138||42||139||Q18340514||events in a specific year or time period||0.019||0.048||1||431,649||0.227||16||0.104||0.133||0.0||0.21||0.068||0.0||0.004|
|42||48||119||Q22808320||Wikimedia human name disambiguation page||0.077||0.075||2||381,873||0.2||19||0.125||0.181||0.0||0.164||0.142||0.0||0.001|
|38||50||117||Q3331189||version, edition, or translation||0.087||0.191||2||374,597||0.197||19||0.126||0.186||0.117||0.037||0.134||0.0||0.038|
Comparison of subgraph queries across time
|Subgraph rank by size||Subgraph||Subgraph label||%of entities||%of triples||Oct query count||Oct %count of queries||Oct query time (hr)||Oct %time of queries||Nov query count||Nov %count of queries||Nov query time (hr)||Nov %time of queries|
|7||Q4167410||Wikimedia disambiguation page||1.459||1.374||3,737,550||1.691||223||1.4||3,292,873||1.728||765||4.982|
|26||Q484170||commune of France||0.043||0.18||866,766||0.392||46||0.3||1,934,902||1.015||70||0.455|
|20||Q13406463||Wikimedia list article||0.352||0.252||1,283,160||0.58||73||0.5||1,766,742||0.927||117||0.765|
|243||Q14204246||Wikimedia project page||0.033||0.008||1,114,113||0.504||62||0.4||498,708||0.262||548||3.572|
|71||Q86850539||Whitaker's Latin frequency type C||0.011||0.048||355,247||0.161||56||0.3||436,103||0.229||95||0.622|
|138||Q18340514||events in a specific year or time period||0.048||0.019||463,683||0.21||17||0.1||431,649||0.227||16||0.104|
|41||Q22808320||Wikimedia human name disambiguation page||0.075||0.078||433,986||0.196||17||0.1||381,873||0.2||19||0.125|
|37||Q3331189||version, edition, or translation||0.19||0.087||410,352||0.186||34||0.2||374,597||0.197||19||0.126|
More on query time
The query time can be broken down to classes for better visualization. Below is a figure with the query class distribution (number of queries per query time class per subgraph) for the top 50 subgraphs. Some of the takeaways are:
- Most subgraphs have most queries in the range of 10-100ms
- Second most commons class is 100ms to 1s
photographhave most queries (~150k) timed at 1-10s. Around 10 more subgraphs have a little (~10-20k) query in this time range.
Analysis on user-agent is an approximation because these don't completely represent distinct users. For example lots people use the same bot or script without changing the user-agent, or the same person or bot uses multiple user-agent strings. Yet based on the available data we can get an estimate nevertheless.
User agent count
- Total number of unique user agents across all subgraphs: 981,180
- First, a list of subgraphs with most and least distinct user-agents is listed. It seems the least number of user-agents a subgraph has is at least 10. So the large subgraphs are used by multiple users.
- The largest numbers of user-agents are present in a variety of type of subgraphs.
gene, protein, biological process, molecular functionappear to be similar among them. It is possible the same queries represent several of these subgraphs. More on subgraph connectivity in #Subgraph Connectivity.
- There are 50 subgraphs with more than 1000 user agents, and 300 subgraphs with less than 1000 user agents. Most subgraphs are therefore not queried overly-widely. The distribution of user-agent counts less than 1000 is shown in the figure below. This clearly shows the small number of user counts in most subgraphs.
User agent distribution in subgraphs
- Next, the user agent vs query count distribution was analyzed for some of the top subgraphs. While user agent count gives us an idea of how many users may be using a subgraph, it is not clear whether all of them query the subgraph equally, or very few user agents perform most of the queries.
- ~30 out of 341 subgraphs have a user agent that queries >=50% of all queries of that particular subgraphs.
- 6 subgraphs have a user agent querying around 80-90% of the time.
- So the trend of dominating single source queries is not wide spread among subgraphs, but is present in few subgraphs nonetheless.
The figure below shows the top 2 user-agent query in percents for 341 subgraphs. This shows whether there is a dominating pattern in a subgraph with the top user agents per subgraph. This figure shows the top 2 user-agent query percents for 341 subgraphs. This shows whether there is a dominating pattern in a subgraph with the top user agents per subgraph.
The figure below shows 100 subgraphs with their user agent query usage distribution in percents. Usage greater than 50% is marked in red. A birds-eye view of the plots shows how some subgraphs have a dominating user agent and most other subgraphs have at least 1 or 2 user agents that query the most. The rest of the user agents form the long tail of the distribution This figure shows 100 subgraphs with their user agent query usage distribution in percents. Usage greater than 50% is marked in red. A birds-eye view of the plots shows how some subgraphs have a dominating user agent while most subgraphs have at least 1 or 2 user agents that query the most. The rest of the user agents form the long tail 10% of the distribution.
Top user agents in subgraphs
- The top user agents in various subgraphs is listed below. More analysis on Q5 (human) and Q16521 (taxon) is done at the end of the page as they are the most queried subgraphs.
|Subgraph||Subgraph label||User agent||Query count (in subgraph)||Query percent (within subgraph)||Query percent overall|
|Q5||human||UA # 2||9017930||13.134||4.079|
|Q5||human||UA # 3||5059258||7.369||2.289|
|Q5||human||UA # 4||4020496||5.856||1.819|
|Q5||human||UA # 5||3828747||5.576||1.732|
|Q101352||family name||UA # 5||3828747||68.811||1.732|
|Q5||human||UA # 6||2685807||3.912||1.215|
|Q5||human||UA # 7||2434486||3.546||1.101|
|Q4830453||business||UA # 8||2403677||59.476||1.087|
|Q5||human||UA # 9||2020598||2.943||0.914|
|Q5||human||UA # 11||1877700||2.735||0.849|
|Q5||human||UA # 12||1781161||2.594||0.806|
|Q16521||taxon||UA # 13||1294113||2.293||0.585|
User agent vs Subgraph
So far we have explored the user-agent count and distribution per subgraph. It is also important to note the user agent's query across subgraphs. In other words,
- Do users have a very specific use case and so the queries spans only a few subgraphs? or is it spread across a lot of subgraphs?
- Are there some user agents that query the most in multiple subgraphs? This could be due to the nature of the use case or simply because some subgraphs overlap a lot.
We start by looking at how many user agents access how many subgraphs. From the table below, we see that most user agents (89% of them) query one subgraphs only. Some user agents query a lot of subgraphs as well. A clearer picture is seem from the plot below.
|File:Ua vs subgraph.png|
Next we isolate user agents from each subgraph who query drastically more (>=10% difference) than other user agents in the same subgraph, and perform at least 100k queries (0.05% of all queries) a month. A list of ~30 such user agents was found. A plot with subgraph distributions of all these user agents was observed to find some large buckets where they tend to query. The plot is shows below, followed by some explicit observations.
Percentages below are percent of all monthly queries.
Subgraph connectivity through queries
Subgraph connectivity was explored to some extent using only Wikidata in Wikidata_Subgraph_Analysis. This was based on what items or properties were common between subgraphs and how many direct connections were present between them. A visualization was created to show the strength of this connectivity between subgraphs here: wikidata_graph. This section aims to analyze the connectivity of subgraphs through the queries, i.e, how often are some subgraphs queried together.
- Subgaph Queries: The total number of queries that touch on at least one of the top 341 subgraps is 72% of all queries.
- First we look at how many subgraphs do most queries access. The tables below show the least and most query groups by number of subgraphs accessed.
- 70% of all queries (97% of subgraph queries) touch on 1 or 2 subgraph. 64% of all queries (90% of subgraph queries) touch on only 1 subgraph.
- It is hard to view which subgraphs occur together from the data above. So the subgraphs that occured together were broken into pairs and pars of subgraphs that occur together the most were listed.
- There are 57,970 subgraphs pairs that occur togther in queries. Total possible subgrah pair count is (340*341)/2 = 57,970. This shows that every subgraph is connected to every other subgraph through queries! Ofcourse the number of queries vary widely.
- A list of some of the most queried subgraphs is shown below.
|Subgraph 1||Subgraph 2||Query|
|Subgraph||Subgraph label||Subgraph||Subgraph label||#of Query||%of Query|
|Q3305213||painting||Q4167410||Wikimedia disambiguation page||629633||0.285|
|Q11424||film||Q14204246||Wikimedia project page||483338||0.219|
|Q4167410||Wikimedia disambiguation page||Q5||human||466217||0.211|
|Q14204246||Wikimedia project page||Q4167410||Wikimedia disambiguation page||436192||0.197|
|Q13406463||Wikimedia list article||Q5||human||394815||0.179|
|Q13442814||scholarly article||Q4167410||Wikimedia disambiguation page||316720||0.143|
|Q13406463||Wikimedia list article||Q18340514||events in a specific year or time period||274841||0.124|
|Q3331189||version, edition, or translation||Q5||human||273761||0.124|
|Q4167410||Wikimedia disambiguation page||Q811979||architectural structure||204572||0.093|
|Q4167410||Wikimedia disambiguation page||Q838948||work of art||200810||0.091|
|Q2225692||fourth-level administrative division in Indonesia||Q532||village||171086||0.077|
|Q3305213||painting||Q838948||work of art||161979||0.073|
- The distribution of the number of times each subgraph pair in wikidata occurs in queries is shown below. Note that (A,B) pair is the same as (B,A) pair, so there is no duplication in the plots. Since the plot is extremely skewed, three plots with various limits on the number of occurrences are shown. We can see how only a small number of pairs occur a lot together, they can be viewed from the table above. Whereas a huge number of pairs occur a very small number of times.
- Below is a heatmap of the number of queries, where both x and y axis represent subgraph indices (names of subgrahps not shown due to space)
- The diagonals show queries that use only 1 subgraph and are represented as Q5-Q5, or Q42-Q42 for example. Other are represented as Q5-Q42 or Q42-Q5
- It is a Symmetrical plot.
- The tons of vertical and horizontal lines indicate there are lots of subgraphs that happen to pair with many other subgraphs.
Human subgraph (Q5) query analysis
The following analysis was done with query data of
The queries that were estimated to be related to the human subgraph accounted for 31.94% of all queries in Wikidata. 31.09% queries used only the human subgraph and the rest 0.85% queries used a mix of human and various other subgraphs. As described in #What are subgraph related queries, subgraphs are related to queries through Properties, Subject or Object URIs, Subgraph instance items, etc. Here is a breakdown for human subgraph taken from #Query count and time. A query can be said to be related to human subgraph due to multiple of the following reasons.
- Number of queries: 60,868,572 (31.94%)
- Percent of queries matching subgraph Qid, i.e, has Q5: 2.54%
- Percent of queries matching instance items: 18%
- Percent of queries matching subject/object URIs: 12%
- Percent of queries matching properties: 19.45%
- Percent of queries matching literal strings: 1.43%
Some of these breakdown have large percentages. It is worth looking at what items/properties/URIs are queried the most. Also looking at the distribution of such items' usage in queries shows how narrow or wide the search space is.
Instance items matched
- Total items used: 7,969,182
- Total queries that use these items: 34,680,808 (18% of all queries)
- The distribution shows there are some high usage (~10k-20k queries) items, a small number of medium usage (~5k queries) items, and rest form a long tail of small usage (<1k queries) items in the human subgraph.
- Total properties used: 1,091 (Recall these are properties that occur 99% of the times in the human subgraph)
- Total queries that use these properties: 37,078,566 (19.45% of all queries)
- The distribution shows there are 3 properties with ~20-30M queries, 7 properties with ~1-5M queries, and rest of the more than 1000 properties match ~100K and less queries. In short, the distribution is a extremely skewed by only ~10 properties that are highly related to the human subgraph.
Subject/Object URI matched
- Total URIs used: 7,926,297 (Recall these are URIs that occur 99% of the times in the human subgraph)
- Total queries that use these URIs: 23,245,152 (12.2% of all queries)
- The top URIs/items show the obvious and most common ways the human subgraph is queried: query about specific people, about groups of people, and about their wikipedia pages. More about types of queries below.
- The distribution is a smooth logarithmic graph with only one item present in 165k queries, and the rest go down from 40k in a logarithmic pattern.
- The total query time of human subgraph is 34% of total query time and total query count is ~32% of all queries.
- Average time per query is 0.3 seconds (300 ms). Most queries in this subgraphs are small and simple.
- The query time distribution is shown in the chart below, both in absolute counts and in percent of queries in human subgraph.
List of top user agents that query human subgraph is given below. This helps us view the distribution of usage - whether few user agents dominate the usage or it is a rather well distributed usage scenario across user agents. Top 10 user agents in terms of query count and also query time is shown in the table below.
|User agent||Query count||% query in human subgraph||% query overall||Query time(hr)||% query time in human subgraph||% query time overall|
The query time breakdown was plotted for the top 20 user agents (in terms of time). Most queries have query time of 10ms to 1s, as observed earlier. Some user agents have most queries in the range 10ms to 100ms and some others have most queries in the range 100ms to 1s.
Taxon subgraph (Q16521) query analysis
The following analysis was done with query data of