Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Convert paramter to wrong type , and causes very large performances problems #254

Closed
xiaobaojiang opened this issue Aug 9, 2018 · 2 comments

Comments

@xiaobaojiang
Copy link

https://github.com/mauricio/postgresql-async/blob/master/postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/column/PostgreSQLColumnEncoderRegistry.scala#L33

 classOf[Int] -> (IntegerEncoderDecoder -> ColumnTypes.Numeric),
    classOf[java.lang.Integer] -> (IntegerEncoderDecoder -> ColumnTypes.Numeric),

    classOf[java.lang.Short] -> (ShortEncoderDecoder -> ColumnTypes.Numeric),
    classOf[Short] -> (ShortEncoderDecoder -> ColumnTypes.Numeric),

    classOf[Long] -> (LongEncoderDecoder -> ColumnTypes.Numeric),
    classOf[java.lang.Long] -> (LongEncoderDecoder -> ColumnTypes.Numeric),

Convert Integer、Long、Short、Float and Double to Numeric , and the attribute of table is Integer or Long, If you use preparedStatement , and will causes larger performances problems.

e.g
Having table users, and has attribute uid with primary key.

  1. use statment and find searching by index
explain analyse select * from users where uid in (200,500,800);
  1. use preparedStatement with correct paramter type, and find searching by index
 PREPARE fooplan (int, int, int) AS
  select *
  from users
  where uid in ($1, $2, $3);
  explain analyse EXECUTE fooplan(200, 500, 800);
  1. use preparedStatement with wrong paramter type, and find searching by seq
  PREPARE fooplan1 (numeric, numeric, numeric) AS
  select *
  from users
  where uid in ($1, $2, $3);
  explain analyse EXECUTE fooplan1(200, 500, 800);
@gabfssilva
Copy link

related to #212 and #241

@oshai
Copy link

oshai commented Sep 17, 2018

I fixed/reverted this in jasync-sql(fork) 0.8.30: jasync-sql/jasync-sql#16 . more details in the issue: jasync-sql/jasync-sql#15

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants