going / casbin-postgres-adapter

PostgreSQL Adapter for Casbin
Apache License 2.0
170 stars 14 forks source link

The performance of SavePolicy() is poor. #3

Open hsluoyz opened 6 years ago

hsluoyz commented 6 years ago

A user complained in Twitter that the performance of saving policy to PostgreSQL is poor. See the below code: https://github.com/going/casbin-postgres-adapter/blob/3a172af64a29a2f4ed8a01d980b00ee06f63143c/adapter.go#L162-L191

Each Casbin policy rule is inserted into DB separatedly with an insert into, which causes the performance downgrade. Can you fix it by inserting all policy rules in one statement? Thanks.

silversquirl commented 5 years ago

It looks like this was "fixed" in 9892155, with the side-effect of adding potential SQL injection. Please can this change be reverted so that this adapter is safe to use again.