Search code examples
siena

With Siena, what is the best way to know if an entity doesn't exist in GAE?


Actually:

return all().filter("name", name).count() == 0;

May be a better way ?


Solution

  • Regarding performance I would go for something like:

    return all().filter("name", name).get() == null;
    

    I'm not sure about GAE but in SQL a limit 1 is several times faster than count, and obviously you don't need to know how many models have this value.