[HACKERS] A little improvementof ApplyLauncherMain loop code
| От | Yugo Nagata |
|---|---|
| Тема | [HACKERS] A little improvementof ApplyLauncherMain loop code |
| Дата | |
| Msg-id | 20170801152815.0c20514c.nagata@sraoss.co.jp обсуждение исходный текст |
| Ответы |
Re: [HACKERS] A little improvementof ApplyLauncherMain loop code
|
| Список | 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@sraoss.co.jp>
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Вложения
В списке pgsql-hackers по дате отправления: