Quickstart example fails, if you don't wait long enough after upsert()

I figured it out… this is just FYI for any other newbies like me:

I created a “gcp-starter” account and got my API key. I ran the python code exactly as listed in Quickstart
The index.upsert() call to insert 5 8-dimensional vectors runs without error, and returns
{'upserted_count': 5}

However, the call to index.describe_index_stats() shows nothing actually happened: vector_count is 0, not 5

{'dimension': 8,
 'index_fullness': 0.0,
 'namespaces': {},
 'total_vector_count': 0}

and of course, index.query() returns no matches.

{'matches': [], 'namespace': ''}

Then I realized the database updates on its own time, and not immediately per-call. So I inserted a 30 second time.sleep() command after the upsert and before the query, and then it worked as expected. So, just FYI.

3 Likes

I was really confused by this too just now–admittedly before reading the docs carefully. The section on inserting data (Insert data) has the following:

Immediately after the upsert response is received, records may not be visible to queries yet. This is because Pinecone is eventually consistent. In most situations, you can check if the records have been received by checking for the record counts returned by describe_index_stats() to be updated. Keep in mind that if you have multiple replicas, they may not all become consistent at the same time.

I’ll suggest an edit in the Quickstart to link to this and hopefully avoid similar confusion for others!

This exact thing got me before trying to help someone debug and turns out they were on gcp-starter which is the only environment that impacts