Commit 3838fa2
committed
Build de-escaped JSON strings in larger chunks during lexing
During COPY BINARY with large JSONB blobs, it was found that half
the time was spent parsing JSON, with much of that spent in separate
appendStringInfoChar() calls for each input byte.
Add lookahead loop to json_lex_string() to allow batching multiple bytes
via appendBinaryStringInfo(). Also use this same logic when de-escaping
is not done, to avoid code duplication.
Report and proof of concept patch by Jelte Fennema, reworked by Andres
Freund and John Naylor
Discussion: https://www.postgresql.org/message-id/CAGECzQQuXbies_nKgSiYifZUjBk6nOf2%3DTSXqRjj2BhUh8CTeA%40mail.gmail.com
Discussion: https://www.postgresql.org/message-id/flat/PR3PR83MB0476F098CBCF68AF7A1CA89FF7B49@PR3PR83MB0476.EURPRD83.prod.outlook.com1 parent a6434b9 commit 3838fa2
1 file changed
+39
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | 689 | | |
699 | 690 | | |
700 | 691 | | |
| |||
849 | 840 | | |
850 | 841 | | |
851 | 842 | | |
852 | | - | |
| 843 | + | |
853 | 844 | | |
| 845 | + | |
| 846 | + | |
854 | 847 | | |
855 | 848 | | |
856 | 849 | | |
857 | | - | |
858 | | - | |
859 | | - | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
860 | 869 | | |
861 | | - | |
862 | | - | |
| 870 | + | |
| 871 | + | |
863 | 872 | | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
868 | 888 | | |
869 | 889 | | |
870 | 890 | | |
| |||
0 commit comments