| From: | Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | A little improvementof ApplyLauncherMain loop code |
| Date: | 2017-08-01 06:28:15 |
| Message-ID: | 20170801152815.0c20514c.nagata@sraoss.co.jp |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
When reading the logical replication code, I found that the following
part could be improved a bit. In the foreach, LWLockAcquire and
logicalrep_worker_find are called for each loop, but they are needed
only when sub->enabled is true.
846 /* Start the missing workers for enabled subscriptions. */
847 foreach(lc, sublist)
848 {
849 Subscription *sub = (Subscription *) lfirst(lc);
850 LogicalRepWorker *w;
851
852 LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
853 w = logicalrep_worker_find(sub->oid, InvalidOid, false);
854 LWLockRelease(LogicalRepWorkerLock);
855
856 if (sub->enabled && w == NULL)
857 {
858 last_start_time = now;
859 wait_time = wal_retrieve_retry_interval;
860
861 logicalrep_worker_launch(sub->dbid, sub->oid, sub->name,
862 sub->owner, InvalidOid);
863 }
864 }
We can fix this to call them only when there are needed, but I'm not sure
whether these call are expensive enough to fix. Is it worth to fix?
A patch attached.
Regards,
--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
| Attachment | Content-Type | Size |
|---|---|---|
| ApplyLauncherMain.patch | text/x-diff | 707 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2017-08-01 06:34:00 | Re: Update description of \d[S+] in \? |
| Previous Message | Simon Riggs | 2017-08-01 06:22:00 | Re: foreign table creation and NOT VALID check constraints |