Re: add modulo (%) operator to pgbench

Поиск
Список
Период
Сортировка
От Mitsumasa KONDO
Тема Re: add modulo (%) operator to pgbench
Дата
Msg-id CADupcHUHTQnB6XPECXX7Pu2=SffzemO6Aku4iObH19rc+k3D_g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: add modulo (%) operator to pgbench  (Mitsumasa KONDO <kondo.mitsumasa@gmail.com>)
Ответы Re: add modulo (%) operator to pgbench  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers
Hi,

Here is the review result.

#1. Patch compatibility
Little bit hunk, but it can patch to latest master.

#2. Functionality
No problem.

#3. Documentation
I think modulo operator explanation should put at last at the doc line.
Because the others are more frequently used.

#4. Algorithm 
You proposed three modulo algorithm, that are 
1. general modulo, 2. floor modulo and 3. euclidian modulo.

They calculate different value when modulo2 or reminder is negative number.
Calculate examples are here, 

1. general modulo (patch1)
    5 %  3 = 2
    5 % -3 = 1
   -5 %  3 = -1

2. floor modulo (patch2, 3)
   5 %  3  =  2
   5 % -3  = -2
  -5 %  3  =  2

3. euclidian modulo (patch2)
   5 %  3  =  2
   5 % -3  =  4
  -5 %  3  =  2

That's all.

I think if we want to create equal possibility and inutuitive random generator, we select floor modulo, as you see the upper example. It can create contrapositive random number. 1 and 2 method cannot.

I think euclidian modulo doesn't need by a lot of people. If we add it, many people will confuse, because they doesn't know the mathematic algorithms.
 
So I like patch3 which is simple and practical.

If you agree or reply my comment, I will mark ready for commiter.

Best Regards,
--
Mitsumsasa KONDO

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: gist vacuum gist access
Следующее
От: Etsuro Fujita
Дата:
Сообщение: Re: Optimization for updating foreign tables in Postgres FDW