Postgres 12.1 uses Index Only Scan Backward instead of index when LIMIT is present

I have a medium sized table (~4M rows) of “functionCalls” which consists of 2 columns, input and function (both ids for another table):

  Column  |  Type   | Collation | Nullable | Default  ----------+---------+-----------+----------+---------  input    | integer |           | not null |   function | integer |           | not null |  Indexes:     "functionCall_pkey" PRIMARY KEY, btree (input, function) CLUSTER     "functionCallSearch" btree (function, input) Foreign-key constraints:     "fkey1" FOREIGN KEY (function) REFERENCES function(id) ON UPDATE CASCADE ON DELETE CASCADE     "fkey2" FOREIGN KEY (input) REFERENCES input(id)  

I want to find all rows that match a certain function, which is why I added the functionCallSearch index. Here is my query:

SELECT c.input FROM "functionCall" c INNER JOIN "function" ON (function.id = c.function) WHERE function.text LIKE 'getmyinode' ORDER BY c.input DESC LIMIT 25 OFFSET 0; 

This takes forever (currently ~ 20s) because pg refuses to use the index, and decides to do a Index Only Scan Backward on the primary key instead:

 Limit  (cost=0.71..2178.97 rows=25 width=4) (actual time=12903.294..19142.568 rows=8 loops=1)    Output: c.input    Buffers: shared hit=59914 read=26193 written=54    ->  Nested Loop  (cost=0.71..135662.48 rows=1557 width=4) (actual time=12903.292..19142.561 rows=8 loops=1)          Output: c.input          Inner Unique: true          Join Filter: (c.function = function.id)          Rows Removed by Join Filter: 3649900          Buffers: shared hit=59914 read=26193 written=54          ->  Index Only Scan Backward using "functionCall_pkey" on public."functionCall" c  (cost=0.43..80906.80 rows=3650225 width=8) (actual time=0.040..17083.489 rows=3649908 loops=1)                Output: c.input, c.function                Heap Fetches: 3649909                Buffers: shared hit=59911 read=26193 written=54          ->  Materialize  (cost=0.28..2.30 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=3649908)                Output: function.id                Buffers: shared hit=3                ->  Index Scan using function_text on public.function  (cost=0.28..2.30 rows=1 width=4) (actual time=0.023..0.026 rows=1 loops=1)                      Output: function.id                      Index Cond: ((function.text)::text = 'getmyinode'::text)                      Buffers: shared hit=3  Planning Time: 0.392 ms  Execution Time: 19143.967 ms 

When I remove the LIMIT this query is blazingly fast:

 Sort  (cost=5247.53..5251.42 rows=1557 width=4) (actual time=3.762..3.763 rows=8 loops=1)    Output: c.input    Sort Key: c.input DESC    Sort Method: quicksort  Memory: 25kB    Buffers: shared hit=6 read=4    ->  Nested Loop  (cost=0.71..5164.97 rows=1557 width=4) (actual time=0.099..3.739 rows=8 loops=1)          Output: c.input          Buffers: shared hit=6 read=4          ->  Index Scan using function_text on public.function  (cost=0.28..2.30 rows=1 width=4) (actual time=0.054..0.056 rows=1 loops=1)                Output: function.id                Index Cond: ((function.text)::text = 'getmyinode'::text)                Buffers: shared hit=2 read=1          ->  Index Only Scan using "functionCallSearch" on public."functionCall" c  (cost=0.43..5103.71 rows=5897 width=8) (actual time=0.039..3.670 rows=8 loops=1)                Output: c.function, c.input                Index Cond: (c.function = function.id)                Heap Fetches: 8                Buffers: shared hit=4 read=3  Planning Time: 0.514 ms  Execution Time: 3.819 ms 

Why is this? And how can I fix this?

I’ve checked https://dba.stackexchange.com/a/249676/106982 but n_distinct is not that far off, pg_stats says n_distinct: 623 while SELECT COUNT(*) FROM (SELECT DISTINCT function FROM "functionCall") returns 1065

I Need to Index T3 Links?

Suppose I have a paid indexer.

Should I send T3 links to my indexer?

With the Exploit and derivatives option, a T3 campaign creates ~ 5000 links in 2 days.

Suppose my indexer is the cheapest, and only accepts 15,000 links per month.

should i spend quota with my indexer with T3 links?

What is your strategy for T3 links?

Should they be left in the wind?

Or is it useless to create them without indexing them?

Options like exploit for example, I believe will never be indexed alone.

I need tips. Thanks

Unity 2D: Can’t resolve ArgumentOutOfRangeException: Index was out of range

I am very much a novice to coding with no background on this at all so the code you see here may be terrible.

Basically I’m making an endless runner, made up of a player character and a set of obstacle prefabs. The obstacle prefabs have a trigger on them so that when the player hits it, it spawns the next prefab. I’m using the code below, and when the player hits the first spawn trigger it will spawn a prefab, but on tripping the next trigger it gives me the ArgumentOutOfRangeException error in the console and doesn’t spawn anything.

public class ObsTrigger : MonoBehaviour {

 public GameObject spawnTrigger;  [SerializeField] private List<Transform> obstacleList;   private void OnTriggerEnter2D(Collider2D other)  {      if (other.CompareTag("Player"))      {          for (int i = 0; i < obstacleList.Count; i++)          {              spawnObstacle();          }      }  }   public void spawnObstacle()  {      {          Transform chosenLevelPart = obstacleList[Random.Range(0, obstacleList.Count -1)];          Instantiate(chosenLevelPart);      }  } 

}

If anyone can point me in the right direction I would really appreciate it!

index links these days

about one year ago option “fetch as google” was removed from search console.

I am using to ping links some websites and sources (rapid indexer) from scrapebox

but i am not successfull

My qusetion is:

How do you index links these days?

If a web crawler get a 404 error, will it not index that url?

Say I have a page page.example.com/page. In my (python) server, you only get served html if you are logged in, which you can do at page.example.com/login. If you aren’t logged in, the server responds with a 404 error.

Does this mean that web-crawlers would be unable to index this page? Or, more accurately, they wouldn’t index it, because it “doesn’t exist”.

Does the order of columns in a covering index matter?

I have the following covering indices:

INDEX (col1, col3); -- index 1 INDEX (col1, col2, col3); -- index 2 

because I would like to support the following type of queries:

1)

  SELECT ...     FROM my_table    WHERE col1 = ... AND          col2 = ... ORDER BY col3 

2)

  SELECT ...     FROM my_table    WHERE col1 = ...  ORDER BY col3 

I am unfamiliar with how a covering index works. Is index 1 redundant? Or does a covering index requires that the columns be side by side?