- Notifications
You must be signed in to change notification settings - Fork5
Commit4e1f986
committed
I found the libpq function PGunescapeBytea a little slow. It was taking a
minute and a half to decode a 500Kb on a fairly fast machine. I think theculprit is sscanf.I attach a patch that replaces the function with one used to perform the sametask in pyPgSQL (a Python interface to PostgreSQL). This code was written byBilly Allie, author of pyPgSQL. I've changed a few variable names to matchthose in the original code and removed a bit of Pythonness.Billy has kindly looked at the code and points out that it is slightlystricter than the original implementation and if it encounters an invalidbytea such as '\12C' it drops the unescape '\' and outputs '12C'.The code is licensed by the author under a BSD license.I've performed limited testing of the function by putting JPEGs intoPostgreSQL, extracting them using them using the new function and diffingagainst the original files.The new function is significantly faster on my machine with the JPEGs beingdecoded in less than a second. I attach a modified libpq example program thatI used for my testing.Ben Lamb.1 parent0abe743 commit4e1f986
1 file changed
+43
-76
lines changedLines changed: 43 additions & 76 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
1690 | 1690 |
| |
1691 | 1691 |
| |
1692 | 1692 |
| |
| 1693 | + | |
| 1694 | + | |
1693 | 1695 |
| |
1694 | 1696 |
| |
1695 | 1697 |
| |
1696 | 1698 |
| |
1697 | 1699 |
| |
1698 | 1700 |
| |
1699 | 1701 |
| |
1700 |
| - | |
1701 |
| - | |
1702 |
| - | |
1703 |
| - | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
1704 | 1707 |
| |
1705 |
| - | |
1706 |
| - | |
1707 |
| - | |
1708 |
| - | |
1709 |
| - | |
1710 |
| - | |
1711 |
| - | |
1712 |
| - | |
1713 | 1708 |
| |
1714 | 1709 |
| |
1715 | 1710 |
| |
1716 | 1711 |
| |
1717 |
| - | |
1718 |
| - | |
1719 |
| - | |
1720 |
| - | |
1721 |
| - | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
1722 | 1715 |
| |
1723 |
| - | |
| 1716 | + | |
1724 | 1717 |
| |
1725 |
| - | |
1726 |
| - | |
1727 |
| - | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
1728 | 1723 |
| |
1729 | 1724 |
| |
1730 |
| - | |
| 1725 | + | |
| 1726 | + | |
1731 | 1727 |
| |
1732 |
| - | |
| 1728 | + | |
1733 | 1729 |
| |
1734 |
| - | |
1735 |
| - | |
1736 |
| - | |
1737 |
| - | |
1738 |
| - | |
1739 |
| - | |
1740 |
| - | |
1741 |
| - | |
1742 |
| - | |
1743 |
| - | |
1744 |
| - | |
1745 |
| - | |
1746 |
| - | |
1747 |
| - | |
1748 |
| - | |
1749 |
| - | |
1750 |
| - | |
1751 |
| - | |
1752 |
| - | |
1753 |
| - | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
1754 | 1734 |
| |
1755 | 1735 |
| |
1756 |
| - | |
1757 |
| - | |
1758 |
| - | |
1759 |
| - | |
1760 |
| - | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
1761 | 1744 |
| |
1762 | 1745 |
| |
1763 |
| - | |
1764 |
| - | |
1765 |
| - | |
1766 |
| - | |
1767 |
| - | |
1768 |
| - | |
1769 |
| - | |
1770 |
| - | |
1771 |
| - | |
1772 |
| - | |
1773 |
| - | |
1774 | 1746 |
| |
1775 |
| - | |
1776 |
| - | |
1777 |
| - | |
1778 |
| - | |
1779 |
| - | |
1780 |
| - | |
1781 |
| - | |
1782 |
| - | |
1783 |
| - | |
1784 |
| - | |
1785 |
| - | |
1786 |
| - | |
| 1747 | + | |
| 1748 | + | |
1787 | 1749 |
| |
1788 | 1750 |
| |
1789 |
| - | |
1790 |
| - | |
1791 |
| - | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
1792 | 1759 |
| |
1793 | 1760 |
| |
1794 |
| - | |
| 1761 | + | |
1795 | 1762 |
|
0 commit comments
Comments
(0)