Re: Which is faster: md5() or hashtext()?

Поиск
Список
Период
Сортировка
От Grzegorz Jaśkiewicz
Тема Re: Which is faster: md5() or hashtext()?
Дата
Msg-id AANLkTimM0HtHrmujgngNPSmGFZPwnHE+XSwqSr6N5-4M@mail.gmail.com
обсуждение исходный текст
Ответ на Which is faster: md5() or hashtext()?  ("Henry C." <henka@cityweb.co.za>)
Ответы Re: Which is faster: md5() or hashtext()?
Список pgsql-general
Timing is on.
psql (9.1devel)
Type "help" for help.

# select count(hashtext(a::text)) FROM generate_series(1,10000) a;
 count
-------
 10000
(1 row)

Time: 106.637 ms
# select count(hashtext(a::text)) FROM generate_series(1,1000000) a;
  count
---------
 1000000
(1 row)

Time: 770.823 ms
# select count(md5(a::text)) FROM generate_series(1,1000000) a;
  count
---------
 1000000
(1 row)

Time: 1238.453 ms
# select count(hashtext(a::text)) FROM generate_series(1,1000000) a;
  count
---------
 1000000
(1 row)

Time: 763.169 ms
# select count(md5(a::text)) FROM generate_series(1,1000000) a;
  count
---------
 1000000
(1 row)

Time: 1258.958 ms


I would say hashtext is consequently beating md5 in terms of performance here.

Just remember, that it returns integer, unlike md5 that returns text.

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

Предыдущее
От: "Henry C."
Дата:
Сообщение: Which is faster: md5() or hashtext()?
Следующее
От: "Andrus"
Дата:
Сообщение: Cloning database without dump/restore