Postgresql pgcrypto和orderby

Postgresql pgcrypto和orderby,postgresql,pgcrypto,Postgresql,Pgcrypto,我想在这样的查询中按某个列排序: SELECT "created", pgp_pub_decrypt(username, dearmor('-----BEGIN PGP PRIVATE KEY BLOCK----- XXXXXXX -----END PGP PRIVATE KEY BLOCK-----'), 'password') AS "username" FROM "users" ORDER BY created 无论我使用哪一列进行排序,计算都需要很长时间。我知道我

我想在这样的查询中按某个列排序:

SELECT "created", 
        pgp_pub_decrypt(username, dearmor('-----BEGIN PGP PRIVATE KEY BLOCK----- XXXXXXX -----END PGP PRIVATE KEY BLOCK-----'), 'password') AS "username" 
FROM "users" 
ORDER BY created
无论我使用哪一列进行排序,计算都需要很长时间。我知道我可以将这个选择包装在另一个选择中并在那里进行排序,但这不是其他原因的解决方案。为什么要花这么长时间?我做错什么了吗

这是查询计划:

QUERY PLAN
-----------------------------------------------------------------------
 Sort  (cost=1261.92..1273.00 rows=4433 width=40)
  Sort Key: created
   ->  Seq Scan on users  (cost=0.00..993.41 rows=4433 width=40)
解释结果(分析、缓冲):


请回答您的问题,并添加使用
explain(analyze,buffers)
(而不仅仅是简单的“explain”)生成的执行计划。求你了,我想时间是用来解密的,不是用来排序的。如果您
解释分析
,您就会知道,如果我不使用排序,则会立即得到排序结果。排序只会给总运行时间增加17毫秒(仅4433行并不奇怪)。大部分时间花在Seq扫描上——可能是函数被调用4433次造成的——但这无法从执行计划中确定。
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
 Sort  (cost=1261.92..1273.00 rows=4433 width=40) (actual time=313515.489..313516.446 rows=4433 loops=1)
   Sort Key: created
   Sort Method: quicksort  Memory: 531kB
   Buffers: shared hit=2037
   ->  Seq Scan on users  (cost=0.00..993.41 rows=4433 width=40) (actual time=70.300..313499.510 rows=4433 loops=1)
         Buffers: shared hit=2037
 Planning time: 0.115 ms
 Execution time: 313517.322 ms