Question about the holdable cursor

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Question about the holdable cursor
Date: 2019-04-18 11:50:45
Message-ID: CAKU4AWrwnqA=2_zDSCBfaUtaGRM09q-8H+6Omju22ucZfaNLZQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

when I fetch from holdable cursor, I found the fact is more complex than I
expected.

suppose we fetched 20 rows.

1). It will fill a PortalStore, the dest is not the client, it is the
DestTupleStore, called ExecutePlan once and receiveSlot will be call 20
times.

2). the portal for client then RunFromStore and send the result to client.
the receiveSlot will be call 20 times again.

3). at last, when we HoldPortal, called ExecutePlan once again and
receiveSlot will be call 20 times

```
0 in ExecutePlan of execMain.c:1696
1 in standard_ExecutorRun of execMain.c:366
2 in ExecutorRun of execMain.c:309
3 in PersistHoldablePortal of portalcmds.c:392
4 in HoldPortal of portalmem.c:639
5 in PreCommit_Portals of portalmem.c:733
6 in CommitTransaction of xact.c:2007
7 in CommitTransactionCommand of xact.c:2801
8 in finish_xact_command of postgres.c:2529
9 in exec_simple_query of postgres.c:1176
10 in exec_docdb_simple_query of postgres.c:5069
11 in _exec_query_with_intercept_exception of op_executor.c:38
12 in exec_op_query of op_executor.c:102
13 in exec_op_find of op_executor.c:204
14 in run_op_find_common of op_find_common.c:42
15 in _cmd_run_find of cmd_find.c:31
16 in run_commands of commands.c:610
17 in DocdbMain of postgres.c:4792
18 in DocdbBackendRun of postmaster.c:4715
19 in DocdbBackendStartup of postmaster.c:4196
20 in ServerLoop of postmaster.c:1760
21 in PostmasterMain of postmaster.c:1406
22 in main of main.c:228
```

why the 3rd time is necessary and will the performance be bad due to this
design?

Thanks for your help!

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2019-04-18 12:02:57 Remove page-read callback from XLogReaderState.
Previous Message John Naylor 2019-04-18 08:40:06 Re: Unhappy about API changes in the no-fsm-for-small-rels patch