Re: notify duplicate elimination performance
От | Hardy Falk |
---|---|
Тема | Re: notify duplicate elimination performance |
Дата | |
Msg-id | 52F67768.2060604@blue-cable.de обсуждение исходный текст |
Ответ на | Re: notify duplicate elimination performance (Andres Freund <andres@2ndquadrant.com>) |
Ответы |
Re: notify duplicate elimination performance
Re: notify duplicate elimination performance |
Список | pgsql-hackers |
> Well, you didn't add any code, so it's hard to say... Simple ways of > doing what I think you describe will remove the queue's order. Do you > preserve the ordering guarantees? > > Greetings, > > Andres Freund > Yes, the order is preserved. I didn't remove the the original list code. The tree is just an additional access path. > oldcontext = MemoryContextSwitchTo(CurTransactionContext); > > n = (Notification *) palloc(sizeof(Notification)); > n->channel = pstrdup(channel); > if (payload) > n->payload = pstrdup(payload); > else > n->payload = ""; > n->hash = hash ; > n->left = NULL ; > n->right= NULL ; > *tt = n ; tt is a Notification** obtained by the search. > static Notification **search(const char *channel, const char *payload ) > { > Notification *t,**tt ; > uint32 hash ; > t = hashroot ; > tt = &hashroot ; > hash = hashf(channel,691) ; > hash = hashf(payload,hash) ; > while ( t ) > { > if ( hash < t->hash ) > { > tt = &t->left ; > t = t->left ; > } > else if ( hash > t->hash ) > { > tt = &t->right ; > t = t->right ; > } > else > { > if (0==strcmp(t->channel,channel) && 0==strcmp(t->payload,payload)) > { > return NULL > } > else > { > tt = &t->left ; > t = t->left ; > } > } > } > return tt ; > }
В списке pgsql-hackers по дате отправления: